Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

using undo with VBA Script

22 views
Skip to first unread message

Corn Bread

unread,
Aug 10, 2004, 10:05:09 AM8/10/04
to corel.graphic_apps.draw-script

Hi,

I have this series of VBA scripts I use for doing Isometric Drawings (see
below). What I'd like to do, is make it so if I make a mistake (not that I
ever do), I can hit Ctrl-Z once to cancel out the whole script, rather than
3 times for every step it goes through. I'm an artist, not a programmer, so
please be gentle when describing anything. Thanks in advance.

Tom


Sub IsoR()
' Description:
' Iso Right
'
ActiveDocument.ReferencePoint = cdrCenter
With ActiveSelection
.Stretch 0.866, 1#
.Move -0.067, 0#
ActiveDocument.ReferencePoint = cdrMiddleLeft
.Skew 0#, 30#
End With
End Sub
Sub IsoL()
' Description:
' Iso Left
'
ActiveDocument.ReferencePoint = cdrCenter
With ActiveSelection
.Stretch 0.866, 1#
.Move 0.206587, 0#
ActiveDocument.ReferencePoint = cdrMiddleRight
.Skew 0#, -30#
End With
End Sub
Sub IsoT()
' Description:
' Iso Top
'
ActiveDocument.ReferencePoint = cdrCenter
With ActiveSelection
.Rotate -45#
ActiveDocument.ReferencePoint = cdrCenter
.Stretch 1.223, 0.707
.Move 0#, 0#
End With
End Sub

Alex Vakulenko

unread,
Aug 11, 2004, 8:57:45 AM8/11/04
to corel.graphic_apps.draw-script

Tom,

Before your script put

ActiveDocument.BeginCommandGroup "Your Command Name"

and after:

ActiveDocument.EndCommandGroup

But make sure you take care of possible run-time error during your macro
execution (if you call BeginCommandGroup without calling EndCommandGroup,
like due to run-time error in between, your document transaction stack will
be corrupt and undo/redo will work very weirdly. You'll have to close and
re-open the document to fix this).

I hope this helps.

P.S. You might be interested in visiting http://www.oberonplace.com/ and its
forums for more support with questions like these...

Alex

Corn Bread

unread,
Aug 12, 2004, 1:21:17 PM8/12/04
to corel.graphic_apps.draw-script

Hi Alex,

Thanks for you response. I'm not sure I really understand this, do you mean
changing it from:

Sub IsoR()
' Description:
' Iso Right
'
ActiveDocument.ReferencePoint = cdrCenter
With ActiveSelection
.Stretch 0.866, 1#
.Move -0.067, 0#
ActiveDocument.ReferencePoint = cdrMiddleLeft
.Skew 0#, 30#
End With
End Sub

to something like this:

Sub IsoR()
ActiveDocument.BeginCommandGroup "Your Command Name"


' Description:
' Iso Right
'
ActiveDocument.ReferencePoint = cdrCenter
With ActiveSelection
.Stretch 0.866, 1#
.Move -0.067, 0#
ActiveDocument.ReferencePoint = cdrMiddleLeft
.Skew 0#, 30#
End With

ActiveDocument.EndCommandGroup "Your Command Name"
End Sub


You still need to have the "Sub" and "End Sub" part in order to begin and
end it , don't you? Let me know, thanks.

Tom

P.S. I have been to your site and found it very useful. Lots of good stuff
there. Some day I need to learn much more about VBA, but right now I'm just
trying to get my job done quickly. Thanks again.

"Alex Vakulenko" <alexv@vakcer_dot_com> wrote in message
news:411a120a$1_3@cnews...

Alex Vakulenko

unread,
Aug 18, 2004, 8:47:53 PM8/18/04
to corel.graphic_apps.draw-script

Something like that. Only EndCommandGroup doesn't have any parameters.

You can find some more examples on this here:
http://www.oberonplace.com/forum/viewtopic.php?p=2162#2162

I hope this helps.

Alex

"Corn Bread" <cornb...@yahoo.com> wrote in message
news:411ba159$1_1@cnews...

SanDee Herman

unread,
Oct 16, 2004, 10:55:08 PM10/16/04
to corel.graphic_apps.draw-script

when using the beginCommandGroup line, u can put any name in the quotes even
with spaces if u want. just make sure its unique to the particular sub /
endsub segment its contained in (or u will undo everything that has that
line in its code!)
try this....


> Sub IsoR()
> ' Description:
> ' Iso Right
> '

> ActiveDocument.BeginCommandGroup "IsoR"


> ActiveDocument.ReferencePoint = cdrCenter
> With ActiveSelection
> .Stretch 0.866, 1#
> .Move -0.067, 0#
> ActiveDocument.ReferencePoint = cdrMiddleLeft
> .Skew 0#, 30#
> End With
> ActiveDocument.EndCommandGroup

> End Sub
at the end of the command group u dont need to identify which command group
u r ending.. it just knows ;)
Hope that helps
best regards
Andy Middleton (im a designer too.... i feel ur pain)

0 new messages