pipSeeker Posted January 19, 2010 Report Share Posted January 19, 2010 Environment: Windows XP/Excel 2007/ MacroExpress 3.7d build 1 *** Will try my best to explain the problem with a scenario... In Excel 2007, I have two Command Buttons, BtnA and BtnB. Each has been programmed using Excel VBA to call separate macros in Macro Express 3.x, say BtnA calls MacroA and BtnB calls MacroB. When I press BtnA, it calls MacroA - correct behavior Then I press BtnB, it calls MacroB - correct behavior Let us say, I now press BtnA. It should call MacroA, but instead it calls the last played macro, MacroB - inconsistent behavior I again press BtnA, this time it calls the correct macro, MacroA - correct behavior It seems as if there is a time lag somewhere in the API call threads, that there is a persistence of previously called macro that leads to above inconsistent behavior. Sometimes it behaves fine, other times, "sticky" behavior as above is exhibited. Would really appreciate any pointers to resolve as it is key for my project that this API calls work! Regards, and thanks in advance! pipSeeker Quote Link to comment Share on other sites More sharing options...
pipSeeker Posted January 20, 2010 Author Report Share Posted January 20, 2010 Any pointers would be really appreciated! The "sticky" inconsistent behavior occurs even if there is more than a minute's gap between calling the two macros. Quite baffled with why this is happening, frankly! Quote Link to comment Share on other sites More sharing options...
paul Posted January 20, 2010 Report Share Posted January 20, 2010 Please show the VBA code that calls the ME3 macros. Quote Link to comment Share on other sites More sharing options...
Yehnfikm8Gq Posted January 20, 2010 Report Share Posted January 20, 2010 While it would seem likely that the problem is in the interface between the programs, have you tried duplicating the button actions not using Excel ie manually starting in ME3, timed similar to the problem to eliminate the possibility it is occurring in the two macros? I can't think of any scenarios in ME3 that would fit, but in all these problems, you start with the simple stuff first and eliminate. Quote Link to comment Share on other sites More sharing options...
kevin Posted January 21, 2010 Report Share Posted January 21, 2010 Are you sure that you are sending the name of the macro followed by a NUL (ASCII 0)? The NUL is supposed to clear the buffer containing the name of the macro. The example from the help looks like this: . . hwnd = FindWindow("TMainWin", "Macro Express Player") For I = 1 To Len(Macroname) Result = PostMessage(hwnd, Command, Asc(Mid(Macroname, I, 1)), 0) Next I Result = PostMessage(hwnd, Command, 0, 0) End Sub Note that the final PostMessage sends the NUL. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.