General discussion
Thread display: Collapse - |
All Comments
Start or search
Create a new discussion
If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.
Opening Excel in VB6 using GetObject
Have a look at the code below:
On Error Resume Next
Set objXl = GetObject(, "Excel.Application")
If Err.Number = 0 Then
blnXlOpen = True
Else
Set objXl = CreateObject("Excel.Application")
blnXlOpen = False
objXl.Visible = True
End If
It uses getobject to see if excel is already open. if so, then it sets a flag, if not, it sets the flag differently and opens excel. I 'recycled' the getobject code from the MSDN library, but here's my problem.
When I try and run the code from within the IDE (i'm using visual studio), I get a 'Run-time error 429 - ActiveXcomponent can't create object'. It highlights the Getobject line as the cause. but.... if I compile the code into an executable, it runs OK!
I reinstalled Office, thinking that its file associations were causing the problem, but that hasn't fixed it. I'm using Office XP.
Any ideas?