Sample Program Geofacts.vbp will not run.

Code line: Set appWorld = GetObject(, "Excel.Application") 'look for a running copy of Excel

Error message: Run-time error'428':

ActiveX component can't create object.

I'm running Excel from Office 2007 on an XP pro machine.

Option Explicit
Public appWorld As Excel.Application
Public wbWorld As Excel.Workbook
Public shtWorld As Excel.Worksheet
Sub Setup()
    ' IMPORTANT: If your machine does not have Excel 97 installed,
    ' you must change the reference to the Excel 95 Object Library.
    ' Then, in the Declarations section above, change the variable
    ' declaration "wbWorld as Workbook" to "shtWorld As Worksheet."
    ' Then change all references to "wbWorld" to "shtWorld."
    On Error Resume Next 'ignore errors
    Set appWorld = GetObject(, "Excel.Application") 'look for a running copy of Excel
    If Err.Number <> 0 Then 'If Excel is not running then
        Set appWorld = CreateObject("Excel.Application") 'run it
    End If
    Err.Clear   ' Clear Err object in case error occurred.
    On Error GoTo 0 'Resume normal error processing
    Set wbWorld = appWorld.Workbooks.Open(App.Path & "\world.xls")
End Sub

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
so you say, that despite the "on error resume next", you get an error pop up on that line?
only in debugging or when running the .exe?
pastxAuthor Commented:
Thanks for responding.  No error in the .exe.  And yes, even though the 'on error', it dies at that line.
Guy Hengel [angelIII / a3]Billing EngineerCommented:
so, you mean you get the "error" when running the code in vb?

right-click anywhere on your code, choose "Toggle" , there will be 3 options.
which one is selected?
try to select " break on unhandled errors"

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pastxAuthor Commented:
I can no longer cause the error.  I rebooted this am and am no longer getting the error.  I have made NO code changes since posting my problem.  Gremlins?  Thanks so much for your help.  I did not know about the right click Toggle.  I'll click the Accept as Solution button on your last comment.
pastxAuthor Commented:
I apologize for taking up your time.  I have no idea what's been going on.  It's working fine now.  Thanks again....
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Applications

From novice to tech pro — start learning today.