Open Excel then a spreadsheet?

  • Thread starter Thread starter James T.
  • Start date Start date
J

James T.

Using Access 2000

I use the following code with Word a lot:

Private Sub Command10_Click()

' start Microsoft Word.
Set wordApp = CreateObject("Word.Application")

With wordApp

' Make the application visible.
.Visible = True
' Open the document.
.Documents.Open
("C:\DataLetters\NoticeToProceed.doc")

I have tried the same thing recently with Excel with:

Private Sub Command10_Click()

' start Microsoft Excel.
Set excelApp = CreateObject("Excel.Application")

With excelApp

' Make the application visible.
.Visible = True
' Open the document.
.Documents.Open
("C:\DataLetters\SpreadsheetTest.xls")

Excel opens, but not the spreadsheet.

Any help greatly appreciated.

Thanks,

James
 
I had tried spreadsheet and it didn't work, so I just
tried your suggestion, Workbook, and it didn't work
either. Thanks for the suggestion, though!

James
 
You might need an 's' but it should work...
xls.Workbooks.Open

AND don't forget to include the Excel Object Library in the
References.
 
Private Sub Command10_Click()

' start Microsoft Excel.
Set excelApp = CreateObject("Excel.Application")

With excelApp

' Make the application visible.
.Visible = True
' Open the document.
.Workbooks.Open "C:\DataLetters\SpreadsheetTest.xls"
' etc. etc. etc.

If you use the CreateObject, you do not need to include reference to EXCEL
in References. ACCESS will do this when it creates excelApp object (called
"late binding"). This actually is preferred over "early binding" (declare
reference to EXCEL in the application's References) because late binding
doesn't require you to know which version of EXCEL is running on the
machine.
 
The "s" worked! Details, details, details! Thanks to Gina
too for responding and the detailed response from Ken. I
really appreciate this group!

James
 
It's the little thing's' that count your welcome!
-----Original Message-----
The "s" worked! Details, details, details! Thanks to Gina
too for responding and the detailed response from Ken. I
really appreciate this group!

James
 
Back
Top