R
Roger Converse
Hello,
Within Access, I am trying to check if an instance of Excel is open. If one
isn't, then I would like to open one. Although the Autotext feature allows
me to key the following:
Dim objXl As Excel.Application
When I put my cursor over it, the message reads "Object variable or with
block variable not set."
When I run the code, I receive an error stating:
I am receiving an error stating "ActiveX component can't create object."
Error 429.
Sample code is below. I am erroring at GetObject(, "Excel.Application").
When Excel is open, the code runs fine. When Excel is closed, I get the
error message.
Any assistance is appreciated.
blnCreated = False
Set objXl = GetObject(, "Excel.Application")
If Err.Number <> 0 Then
blnCreated = True
Set objXl = CreateObject("Excel.Application") 'for late binding
End If
With objXl.Application
.Visible = True
.Windows("Personal.xls").Activate
.Run "module1.macOpenPO"
End With
If blnCreated = True Then objXl.Quit
I have the references for Excel 11.0 checked in Tools | References, so am
not sure if I am missing something else there.
Thank you,
Roger
Within Access, I am trying to check if an instance of Excel is open. If one
isn't, then I would like to open one. Although the Autotext feature allows
me to key the following:
Dim objXl As Excel.Application
When I put my cursor over it, the message reads "Object variable or with
block variable not set."
When I run the code, I receive an error stating:
I am receiving an error stating "ActiveX component can't create object."
Error 429.
Sample code is below. I am erroring at GetObject(, "Excel.Application").
When Excel is open, the code runs fine. When Excel is closed, I get the
error message.
Any assistance is appreciated.
blnCreated = False
Set objXl = GetObject(, "Excel.Application")
If Err.Number <> 0 Then
blnCreated = True
Set objXl = CreateObject("Excel.Application") 'for late binding
End If
With objXl.Application
.Visible = True
.Windows("Personal.xls").Activate
.Run "module1.macOpenPO"
End With
If blnCreated = True Then objXl.Quit
I have the references for Excel 11.0 checked in Tools | References, so am
not sure if I am missing something else there.
Thank you,
Roger