I am a wannabe VB programmer, and as such, am still learning the ropes. I am writing a little app to help a colleague generate reports on an excel spreadsheet he uses daily.
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?