BeginUndoScope now showing in Undo menu

A

Aussie Susan

(Visio 2003)

I have a macro that is called via a button on my custom toolbar. The macro is:

Public Sub ResourceLevelling()
Dim UndoID As Long
UndoID = Application.BeginUndoScope("Resource Levelling")

' stuff is done here

Application.EndUndoScope UndoID, True
End Sub

When the whole thing completes, the Edit->Undo text reads "Undo Go To Page"
(there is code to change the page within the functions called by the macro).

I understood that the 'Undo Resource Levelling" text should appear in this
menu location (and this is what I want).

As it turns out, if I select the mislabelled undo option (or type Ctrl/Z)
then the whole thing IS undone. However, the text is misleading for the
people who will be ultimately using this Visio stencil/diagram.

Is there something else I need to do to get my text displayed.

Thanks

Susan
 
P

Paul Herber

(Visio 2003)

I have a macro that is called via a button on my custom toolbar. The macro is:

Public Sub ResourceLevelling()
Dim UndoID As Long
UndoID = Application.BeginUndoScope("Resource Levelling")

' stuff is done here

Application.EndUndoScope UndoID, True
End Sub

When the whole thing completes, the Edit->Undo text reads "Undo Go To Page"
(there is code to change the page within the functions called by the macro).

Does your "stuff is done here" bit include a goto page? I'll guess
that between the begin and end scope there is another undo scope being
set.
Comment out all the "stuff" but leave just some minimal bit. Does that
leave your "Resource Levelling" in the undo list?
 
A

Aussie Susan

:

(edited by Susan)
Does your "stuff is done here" bit include a goto page? I'll guess
that between the begin and end scope there is another undo scope being
set.
Comment out all the "stuff" but leave just some minimal bit. Does that
leave your "Resource Levelling" in the undo list?

Thanks for the suggestion. I tried that but the outcome is the same. The
method code is now

Public Sub LevelResources()
Dim UndoID As Long
UndoID = Application.BeginUndoScope("Resource Levelling")
Application.EndUndoScope UndoID, True
End Sub

and this does not alter the text of the 'Undo' menu option. I changed a
value (using one of the forms in the code I'm writing), and the text became
'Undo Set Formula'. I then triggered off the macro and the undo text remained
the same!

I also tried running the procedure (within the debugger usingthe F5 key and
stepping through it with the F8 key, and with the 'Tools -> Run Macro...'
dialog) and still the same outcome!

Is there some option that needs to be set somewhere for this to work? The
reason I ask is that I've seen some examples where a 'Recorded' macro is
surrounded by Begin/End undo scope statements that are generated by Visio,
but I don't seem to get them when I try recording something.

By the way, the answer to your question about there being a 'Go To Gage' in
the executed code, there is none there directly, but I have used the
following (and similar) in some places:
Application.ActiveWindow.Page = GetModelPage
where GetModelPage returns a page reference. However, I would have thought
that either Visio would 'nest' these undo blocks, merge then or something
like that. In any case, it should be listing the LAST 'EndUndoScope'

Susan
 
P

Paul Herber

:

(edited by Susan)


Thanks for the suggestion. I tried that but the outcome is the same. The
method code is now

Public Sub LevelResources()
Dim UndoID As Long
UndoID = Application.BeginUndoScope("Resource Levelling")
Application.EndUndoScope UndoID, True
End Sub

I don't know off hand, similar code in my own applications works fine,
but my code is written and compiled in Delphi, the Long is an Integer
and it's also at the module global level, I can't see that making any
difference.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top