Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Gazzer
Contributor
Contributor

WaitForIdle Fails in PostReload Macro

I have a macro which copies the data from multiple charts and pastes into an Excel file. To try to minimize the clipboard failure issue I have inserted WaitForIdle commands throughout, as well as the WshShell command to clear the clipboard.

This seems to work pretty well when tested - mainly by using a button to call the macro, but also when testing inside the macro editor.

Now I have added the macro to the OnPostReload trigger, the intention being to call the QVW file from a batch file using the /r flag to reload the data. In this instance, the macro always fails as soon as it hits the WaitForIdle command. 

I have tried lots of different ways to work around this, but without coming to an actual solution. I assume the failure has something to do with the fact that the QVW is closed when the macro is running.

If I use the /l flag in the batch file, it works in terms of loading the data and running the macro, but then the file is left unsaved and open, which means the batch file stops and everything is left open on the desktop - I have not tested the effect of this when the batch is next run.

I tried moving the macro to the OnOpen trigger, but this didn't work either. Anyone have any suggestions?

I'm using QV12 SR1

1 Solution

Accepted Solutions
marcus_sommer

Yes, it could not work with /r but with /l and you need only to add a save/close/quit command after your exports. The following links should be good starting point for your task:

Run-a-macro-on-post-reload
Sending-mails-macro-vbs

- Marcus

View solution in original post

3 Replies
marcus_sommer

Yes, it could not work with /r but with /l and you need only to add a save/close/quit command after your exports. The following links should be good starting point for your task:

Run-a-macro-on-post-reload
Sending-mails-macro-vbs

- Marcus

Brett_Bleess
Former Employee
Former Employee

As Marcus has noted, the OnPostReload trigger along with /r is not recommended, as there is an inherent conflict that occurs, the /r is attempting to shut the reload process down, but the OnPostReload trigger is attempting to run a macro...  In addition to what Marcus put out, the other option might be to use a Binary load in a new app with the macro you want to run and us the OnOpen trigger there and put an exit in your macro to close things out, you will need a trigger to fire the other batch process, but that should work consistently I believe.

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.
Brett_Bleess
Former Employee
Former Employee

LOL, and I just realized my logic is flawed here as well, OnOpen is going to run before the Binary load I think, so that may not work, sorry, been a long day, but at least you know why the OnPostReload will not work, hopefully one of Marcus' ideas will pan out.

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.