OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 20-08-2006, 12:05
vindaa
Guest
 
Posts: n/a
Default How to undo macro as a single command

I use several macros in corel draw it saves lot of time. Actually I am novice for VB, but I use cut paste method and achieve what I want by trying to understand the codes, It really works for me.

Here is my question. After executing a macro, when I use undo command, (using 'Ctrl Z') -- I go back only one step and not all actions of macros are undone. How can I make corel draw treat the whole macro as one single command.

So when I press Ctrl Z whole macro is undone.
Reply With Quote
  #2  
Old 20-08-2006, 13:23
Sablesword Sablesword is offline
Junior Member
 
Join Date: Aug 2006
Posts: 20
Default

You can do that by ActiveDocument.BeginCommandGroup e.g.

Code:
ActiveDocument.BeginCommandGroup "my crunchy macro"

[stuff in the macro you want to undo in one swell foop here]

ActiveDocument.EndCommandGroup
where "my crunchy macro" is what shows up in the Edit menu as

Edit
-> Undo my crunchy macro
-> Redo my crunchy macro

Hope this helps.
Reply With Quote
  #3  
Old 20-08-2006, 16:29
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,778
Blog Entries: 10
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Undo

I would just add to this that it is important to include an error handler, so your undo stack does not become corrupt if something goes wrong. So something like this works great:
Code:
Sub Test()

ActiveDocument.BeginCommandGroup "My Command"

On Error Goto ErrHandler
' Place your code here

ExitSub:
ActiveDocument.EndCommandGroup
Exit Sub

ErrHandler:
MsgBox "Error occured: " & Err.Description
Resume ExitSub

End Sub
I know it is a little more code, but if there are problems, it is nice to catch them.

Shelby
Reply With Quote
  #4  
Old 20-08-2006, 22:39
vindaa
Guest
 
Posts: n/a
Default Undo of macro as a single command

Thanks both of you it works great. Priviously it use to take away my ability to undo 100 times.

Thanks once again
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot use Curveworks macros in a user witten macro??? jon46089 CurveWorks 2 02-03-2006 15:18
Help with Replace Macro Pumpkin_Masher Macros/Add-ons 1 21-09-2005 15:41
musthave macro: REPEAT LAST COMMAND custom number of times wOxxOm CorelDRAW/Corel DESIGNER VBA 3 04-09-2005 13:08
Clearing Undo List lasergraver CorelDRAW/Corel DESIGNER VBA 4 15-08-2004 12:34
New macro to clip curves w.r.t. a border Gerard Hermans Macros/Add-ons 0 09-06-2003 08:50


All times are GMT -5. The time now is 23:46.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com