ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Opening Files (https://www.excelbanter.com/excel-programming/279766-opening-files.html)

Dave[_32_]

Opening Files
 
Hi

Could someone provide me with code to do the following please:

While using Access I and need to open an Excel spread sheet then save it. I
can do this using Excel only, but need to do this within Access

Please help


Dave

--
Please type david.com inplace of no.thanks.
Sorry for the inconvenience but fed up of spam mail.



Tom Ogilvy

Opening Files
 
Look in VBA help for createobject and getobject

Dim xlApp as Object
Dim xlBook as Object
Dim xlSheet as Object
set xlApp = CreateObject("Excel.Application")
set xlBook = xlApp.Workbooks.Open "C:\My Folder\MyFile.xls"
' or
'Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
xlSheet.Cells(1,1).Value = 1
xlBook.Save
' or xlBook.SaveAs "C:\My Folder\MyFile1.xls"
xlBook.close SaveChanges:=False
set xlsheet = nothing
set xlBook = nothing
xlApp.Quit
set xlApp = Nothing

some references:
http://support.microsoft.com/support...aqVBOffice.asp
Frequently Asked Questions about Microsoft Office Automation Using Visual
Basic


http://support.microsoft.com/support...fdevinapps.asp
Programming Office from Within Office

http://support.microsoft.com/support...dev/iisfaq.asp
Integrating Office with IIS FAQ

http://support.microsoft.com/?id =219151
Q219151 - HOWTO: Automate Excel 97 and Excel 2000 from Visual Basic

http://support.microsoft.com/support...automation.asp
Using Automation with Microsoft Excel 97

http://support.microsoft.com/?id=153748
ACC: How to Call Excel Functions from Within Microsoft Access

Automating Excel from VB and from Access is identical.

--
Regards,
Tom Ogilvy

"Dave" wrote in message
...
Hi

Could someone provide me with code to do the following please:

While using Access I and need to open an Excel spread sheet then save it.

I
can do this using Excel only, but need to do this within Access

Please help


Dave

--
Please type david.com inplace of no.thanks.
Sorry for the inconvenience but fed up of spam mail.





Tom Ogilvy

Opening Files
 
Here are two mo

http://support.microsoft.com/?id=153748
ACC: How to Call Excel Functions from Within Microsoft Access

http://support.microsoft.com/?id=167223
Microsoft Office 97 Automation Help File Available on MSL

--
Regards,
Tom Ogilvy

"Dave" wrote in message
...
Hi

Could someone provide me with code to do the following please:

While using Access I and need to open an Excel spread sheet then save it.

I
can do this using Excel only, but need to do this within Access

Please help


Dave

--
Please type david.com inplace of no.thanks.
Sorry for the inconvenience but fed up of spam mail.






All times are GMT +1. The time now is 03:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com