byrnedhead
New Member
- Joined
- Aug 15, 2007
- Messages
- 1
This is a rather esoteric problem, but I hope someone can help me.
I'm working on a VBA macro which exports a few MS Access query tables to an Excel workbook and then does extensive formatting to turn the data into a human-readable report. I'm opening Excel from within Access thus:
The problem is that when the user closes Excel after the macro has run, the excel.exe process does not get terminated. If the macro is run more than once, then VBA throws error 91, "Object variable or With block variable not set", at several places in the VBA code. This usually involves references to the ActiveWorkbook property; I'm guessing that the VBA is confused by the multiple excel.exe processes. I can re-write the code to clarify any references that have this problem, but it would be better if the excel.exe processes just closed normally like they're supposed to. Is there an alternate method of opening Excel that doesn't have this problem?
Thanks for any help. This is all in Excel/Access 2003.
I'm working on a VBA macro which exports a few MS Access query tables to an Excel workbook and then does extensive formatting to turn the data into a human-readable report. I'm opening Excel from within Access thus:
Code:
Dim NewExcel As New Excel.Application
NewExcel.Visible = True
Thanks for any help. This is all in Excel/Access 2003.