Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

The "Undo" Problem after running a macro

Status
Not open for further replies.

AlvaroPers

Mechanical
Nov 29, 2020
30
thread560-95318

Hello,
I have the following situation:

I run a program (using visual basic under Visual Studio) to change instances name. The program works just fine.
I have the following lines in case the user "cancel" the renaming and wants to go back with the changes:

Private Sub Cancel_Click(sender As Object, e As EventArgs) Handles Cancel.Click
If flag = True Then
myCATIA.StartCommand(iCommandId:="Undo")
End
ElseIf flag = False Then
End
End If
End Sub

I noticed that once the renaming took place, before closing the form if I go to the CATIA window and make a mouse click at anyplace in the geometric area, then "undo" action works well.
In the opposite, if I don't click the CATIA window the behavior is different, the "undo" action doesn't work, and the " Unavailable command: Undo" appears.
I've tried unsuccessfully to use the API in order to use the functions "FindWindowsEx" to get the window and then make a "postMessage" to simulate a mouse click, but I couldn't get it work.

My question is, has anybody found a solution to use the undo command after running a program?

Thank you.
Alvaro.


 
Replies continue below

Recommended for you

It is solved, since when using the resulting ".exe" program the undo works just fine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor