Results 1 to 6 of 6
  1. #1
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544

    Question Run-time '429': ActiveX component can't create object

    I have the below function that always crashes on the highlighted line. I have the following libraries added....Help please.

    Libraries:
    Visual Basic For Applications
    MS Access 14.0 Object Library
    OLE Automation
    MS Office 14.0 Access database engine Object Library
    MS Excel 14.0 Object Library


    MS Outlook 14.0 Object Library

    Code:
    Function IsExcelRunning() As Boolean
        Dim xlApp As Excel.Application
    'On Error Resume Next
        Set xlApp = GetObject(, "Excel.Application")
        IsExcelRunning = (Err.Number = 0)
        Set xlApp = Nothing
        Err.Clear
    End Function

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    you should not be using GETOBJECT when you've created it with a DIM. when you DIM an excel object, you need to use the NEW keyword. that will start the actual program process, if I remember right. dimming a var as an excel object doesn't initialize the program (I don't think). it simply assigns a type of object to the var. This looks like late binding and early binding combined, which aren't meant to work together.

    try replacing that line with:
    Code:
    SET xlApp = NEW excel.application
    that will start it. but you won't be able to see it unless you changed it's .visible property afterwards.

  3. #3
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Great, thanks for the explanation!

  4. #4
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Adam - I just reviewed the code. I am actually attempting to check of Excel is already open. So maybe I'm approaching this from the wrong angle?

  5. #5
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by jgelpi16 View Post
    Adam - I just reviewed the code. I am actually attempting to check of Excel is already open. So maybe I'm approaching this from the wrong angle?
    you want to CHECK to see if it's open? well there's a number of ways you can do that. the easiest would be to throw an error on purpose. for instance, use this code:
    Code:
    Set xlApp = GetObject(, "Excel.Application")
    run it, capture the err.number it throws and put an err routine in it for that number. If the err.number = 0, obviously it's already open. OK...NOT "open", but the process is running. that's what GETOBJECT() does (I think). It'll fail if the process isn't running.

    the other way would be to loop your system process list, but obviously that takes more code. it takes an API, which I have in my archives. but the err method is better, to me anyway.

  6. #6
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    That helped. The code I was actually running was correct. I commented out the "On Error Resume Next" piece, which was part of the functionality. Your above explanation triggered my thought process. Thank you.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 03-03-2011, 12:48 PM
  2. Replies: 4
    Last Post: 08-02-2010, 06:31 AM
  3. Run-time error '424': Object required
    By cowboy in forum Programming
    Replies: 18
    Last Post: 07-07-2010, 03:32 PM
  4. Replies: 0
    Last Post: 10-20-2009, 01:10 PM
  5. ActiveX componet can't create object
    By quanmay35 in forum Access
    Replies: 1
    Last Post: 05-26-2009, 05:27 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums