PDA

View Full Version : callback for Application.Run



fb7894
12-20-2017, 01:32 PM
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"

MINCUS1308
12-21-2017, 08:11 AM
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.

Kenneth Hobs
12-21-2017, 08:37 AM
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