Open Excel then a spreadsheet?

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
 
J

James T.

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
 
G

Gina

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.
 
K

Ken Snell

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.
 
J

James T.

The "s" worked! Details, details, details! Thanks to Gina
too for responding and the detailed response from Ken. I
really appreciate this group!

James
 
G

Gina

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top