method 'add' of object 'workbooks' failed

Joined
May 6, 2010
Messages
4
Reaction score
0
Hello,
I know this is an old problem, but I have looked through everything I can find and I can not figure this out.

I am trying to create a module in Access 2007 that will create a new excel spreadsheet. It gets hung up when it tries to Add a workbook. Here is the code:

Sub ExcelTest()


Dim xlApp As Excel.Application
Dim xlWB As Excel.Workbook
Dim xlSheet As Object


Set xlApp = New Excel.Application
xlApp.Visible = True

Set xlWB = xlApp.Workbooks.Add

--

When it gets to the line:
Set xlWB = xlApp.Workbooks.Add
it fails and I get the error "Method 'Add' of Object 'Workbooks' failed"

I am running Access 2007 on my Vista platform. This code works perfectly at work using Office 2003. I have tried rolling back my references to earlier versions and I still get the same error. I don't know why it is not working, this is driving me nuts. Please help.
 
Back
Top