Excel automation to access a workbook

D

DZ

I want to utililze Excel Automation to obtain properties from an Excel
workbook.

Given path of the Excel workbook, how can I get the properties of a workbook
without making the Excel application or the workbook visible.

Then obviously close the Excel workbook and the Excel Object after I get the
properties

Any help with this would be appreciated
 
D

DZ

Here is some code I am using. I need help getting it to work. When I run it,
I get an error message

"Run-time error '-2147417851 (80010105)' Method 'Open' of object
'Workbooks' failed"

I am in a form in Access 97 trying to access Excel 97 through automation. OS
Win XP
In the current database i have set a references to
Microsoft Excel 8.0 Objct Library
Microsoft Officel 8.0 Objct Library


Sub AccessWorkbook()
Dim xlApp As Excel.application
Dim xlwbBook As Excel.Workbook
Dim stFile As String

stFile = "C:\New Files\Data.xls"

'Instantiate a new session with the COM-Object Excel.exe
Set xlApp = New Excel.application

Set xlwbBook = xlApp.Workbooks.Open(stFile)

MsgBox xlwbBook.Names(1).Name

'Close Excel.
xlApp.Quit

'Release the COM-objects from memory.

Set xlwbBook = Nothing
Set xlApp = Nothing


End Sub
 

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