How to consider a macro as a unique command for Cancel ?

How to consider a macro as a unique command for Cancel ?

TONELLAL
Collaborator Collaborator
471 Views
2 Replies
Message 1 of 3

How to consider a macro as a unique command for Cancel ?

TONELLAL
Collaborator
Collaborator

Hello,

I have several VBA macro that manipulate an Inventor file. For example :

Sub My_Macro()

   Action 1

   Action 2

   Action 3

End sub

 

When I use ctrl-Z, this cancel Action 3, then Action 2, then Action 1.

Is it possible to cancel the whole macro with only one ctrl-z ?

0 Likes
Accepted solutions (1)
472 Views
2 Replies
Replies (2)
Message 2 of 3

JelteDeJong
Mentor
Mentor
Accepted solution

Have a look at "Transactions". Your code would look like this:

 

Sub My_Macro()
	Dim oTransMgr As TransactionManager
	Set oTransMgr = ThisApplication.TransactionManager
	Dim oTrans As Transaction
	Set oTrans = oTransMgr.StartTransaction(ThisApplication.ActiveDocument, "Create Triangle") 
	
	Action 1
	Action 2
	Action 3
	
	oTrans.End 
End Sub

more info can be found on:

 

https://modthemachine.typepad.com/my_weblog/2009/03/combining-multiple-actions-into-a-single-undo.ht... 

or have a look at the programing help and search for "TransactionManager"

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 3 of 3

TONELLAL
Collaborator
Collaborator

Perfect ! Exactly what I was looking for.

0 Likes