Macro Toolworks Products Discussion Forums :: General Discussion
Welcome Guest   
 Subject :waitfor WIN OPEN not working with Excel popups.. 11-01-2012 05:00:57 
matthew_hoffmann@dell.com
Joined: 11-01-2012 03:46:45
Posts: 2
Location
Using 7.4.8

To recreate - add a new module to an Excel workbook with the following;
Code:
Sub A() Response = MsgBox("Macro Complete.", 0, "Macro Complete") End Sub


Then create a new PKB Macro;
Code:
{keys} {alt}{F8}{alt} {waitfor}("WIN","OPEN","[#Microsoft Excel - Book1.xlsm|XLMAIN|#2135|#77]\[Macro|bosa_sdm_XL9|#734|#324]",0,0) {enter} {waitfor}("WIN","OPEN","[#Microsoft Excel - Book1.xlsm|XLMAIN|#2135|#77]\[Macro Complete|\#32770|#619|#476]",0,0) {enter} {waitfor}("WIN","CLOSE","[#Microsoft Excel - Book1.xlsm|XLMAIN|#2135|#77]\[Macro Complete|\#32770|#619|#476]",0,0) {msg}(-100,-100,"Success","Message",1,0,0,1)
Replace { with < and } with > .

Go back to Excel, run the PKB macro, and it will just wait forever with the "Macro Complete" popup open in Excel.

What am I missing? I need PKB to wait for a VBA macro to complete, the duration of which can vary widely, and then take further action. I can signify the end of a VBA macro with a popup - is there a better way to solve this, or soome function of win open I'm missing?
IP Logged
 Subject :Re:waitfor WIN OPEN not working with Excel popups.. 20-01-2012 19:45:07 
petr
Joined: 15-10-2009 11:48:52
Posts: 152
Location
Hello,

I do not know what version of the Excel you use (I use 2010) but instead of "Book1.xlsm" in the Excel window title I see just "Book1". So you may want to try to replace Book1.xlsm by Book1 in the <waitfor> command.

I was able to get you example (modified, I removed this Alt+F8 and entering) to work OK, the <waitfor> command detected the VBA "Macro Complete" message box.

Best regards,
Petr
IP Logged
 Subject :Re:waitfor WIN OPEN not working with Excel popups.. 23-01-2012 21:21:10 
matthew_hoffmann@dell.com
Joined: 11-01-2012 03:46:45
Posts: 2
Location
I'm using 2010 as well. Per your suggestion, I took out the step to initiate the Excel macro window, and the waitfor win open works perfectly.

The problem is, I need the macro to do both steps - Send the keystrokes alt-F8, initiate the macro and then wait for the popup. Is there a way to make both steps work in the same macro?
IP Logged
 Subject :Re:waitfor WIN OPEN not working with Excel popups.. 02-02-2012 17:29:05 
petr
Joined: 15-10-2009 11:48:52
Posts: 152
Location
Hello,

I do not see why it should not work... Just I would modify the macro this way (adding <cmds> command):

<alt><F8><alt><cmds>
<waitfor>(....)

This will prevent macro from sending "Enter" newline after Alt+F8 hotkey which your original macro was doing (which could eventually close the currently opened message box).

Best regards,
Petr
IP Logged
Page # 


Powered by ccBoard


Login and share your experience - send messages to forums and add comments to samples, commands and other resources.



Account is free of charge, easy to setup.