camprunamuk
Technical User
I am using macros in Attachmate to display a series of text files in Notepad. Previously, a user would have to close Notepad and then trigger the macro to ask for the next file. I am now trying to add an automatic close into the macro using the following code:
AppActivate "TempEDI1 - Notepad"
SendKeys "%{F4}", True
DoEvents
Later in the code, I re-activate Attachmate and continue as before. The good news is that it works most of the time...that's also the bad news! This fails once per day in only one scenario: The second time that the macro is triggered since initial start-up or re-start, the Notepad button on the Windows toolbar highlights, but does not depress and the Notepad does not receive focus. The Alt+F4 gets sent to the Attachmate window and it tries to close. Since this happens during the macro, we get an error message that says "You can't exit while a macro is running." Then the macro runs perfectly for the remainder of the day (300-500 more times!). I would have expected this to fail when the targeted file wasn't open in Notepad, but it doesn't even try when that is the case.
Any help anyone can offer would be greatly appreciated. Thanks!
AppActivate "TempEDI1 - Notepad"
SendKeys "%{F4}", True
DoEvents
Later in the code, I re-activate Attachmate and continue as before. The good news is that it works most of the time...that's also the bad news! This fails once per day in only one scenario: The second time that the macro is triggered since initial start-up or re-start, the Notepad button on the Windows toolbar highlights, but does not depress and the Notepad does not receive focus. The Alt+F4 gets sent to the Attachmate window and it tries to close. Since this happens during the macro, we get an error message that says "You can't exit while a macro is running." Then the macro runs perfectly for the remainder of the day (300-500 more times!). I would have expected this to fail when the targeted file wasn't open in Notepad, but it doesn't even try when that is the case.
Any help anyone can offer would be greatly appreciated. Thanks!