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
THE FOLLOWING LINE IS THE PROBLEM!!!!
    Set appWorld = GetObject(, "Excel.Application") 'look for a running copy of Excel
END OF PROBLEM LINE!!!!
    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

pastxAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Guy Hengel [angelIII / a3]Connect With a Mentor 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"
0
 
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?
0
 
pastxAuthor Commented:
Thanks for responding.  No error in the .exe.  And yes, even though the 'on error', it dies at that line.
0
 
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.
0
 
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....
0
All Courses

From novice to tech pro — start learning today.