Consulting

Results 1 to 3 of 3

Thread: callback for Application.Run

  1. #1
    VBAX Regular
    Joined
    Jun 2008
    Posts
    72
    Location

    callback for Application.Run

    Hello. I have a macro where i want to call a third-party add in and then crunch some numbers after the third-party add in has updated the sheet.

    The problem is, use Application.Run "gvRefresh" to call the add-in code. But the add-in does not return records until my macro finishes.

    i'm guessing this is because you can only run one macro at a time? I have tried DoEvents and Application.Wait with no luck.

    Any suggestions? Here is my code...

    Set wbArbTracker = Workbooks.Open(shtMain.Range("ArbTrackerPath"), , True)    
    Application.Run "gvRefresh"
        DoEvents
        Application.Wait (Now + TimeValue("0:00:10"))
        ' the gvRefresh should have returned additional rows to my spreadsheet, but it's not"
    Last edited by fb7894; 12-20-2017 at 03:17 PM.

  2. #2
    VBAX Tutor MINCUS1308's Avatar
    Joined
    Jun 2014
    Location
    UNDER MY DESK
    Posts
    254
    not returning records?
    you might just throw this in after your .run statement
    Application.ScreenUpdating = True
        ActiveWorkbook.RefreshAll
    Also, are you positive that the gvRefresh is going to add lines?
    perhaps it is working as designed but the outcome is not what you expected?

    alternatively,
    verify that excel is returning to your macro after finishing the gvRefresh and not doing something stupid.
    throw:
    MsgBox "I made it back to the calling macro"
    in after your application.wait statement and run
    if it pops up with the message box youre all set.
    Last edited by MINCUS1308; 12-21-2017 at 08:12 AM. Reason: grammer nazi
    - I HAVE NO IDEA WHAT I'M DOING

  3. #3
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Does your macro use Shell()? If so, it needs to wait I suspect.

    e.g.
    http://www.cpearson.com/Excel/ShellAndWait.aspx
    or
    http://www.mvps.org/access/api/api0004.htm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •