Workbooks not found as a member

T

troy_lee

I am writing code in Access. I want to initialize Excel. I found some
code that looked good and massaged it for my purposes. I am getting a
failure "Method or data member not found" at the
objXLApp.Workbooks.Open (strDocPath) line. Can someone please tell me
what I am doing wrong? Workbooks is clearly a member of the Excel
application class.

Thanks in advance for the help.

Private Sub cmdTest_Click()
Dim objXLApp As Application
Dim strDocPath As String
'Full path and name of template
Dim strPath As String
'Full path and name to save file as

strDocPath = "C:\Scorecard\Scorecard Template.xls"
strPath = "C:\Scorecard\Files\"

Set objXLApp = CreateObject("Excel.Application")
objXLApp.Workbooks.Open (strDocPath)
objXLApp.ActiveWorkbook.SaveAs (strPath)



End Sub
 
D

Daniel.C

Go to Tools, References and select "Microsoft Excel xx Object Library";
Replace :
Dim objXLApp As Application
with :
Dim objXLApp As Excel.Application
 

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