PDA

View Full Version : Undo AutoFormat w/DocumentMap = True



mansky
08-25-2006, 11:15 AM
Hi All,
When I open an existing Document with the DocumentMap turned off and I turn it on by explicitly selecting it under the "View" menu option, I then see "Undo AutoFormat" under the "Edit" menu option. What VB command does "Undo AutoFormat" correspond to in this case ? I tried to Record a macro to find out the command, but when the Record macro toolbar is up, the "Undo AutoFormat" option under "Edit" is greyed-out.


Any tips or ideas would be greatly appreciated! Thanks!!

Ed

lucas
08-25-2006, 11:24 AM
Not sure but this might help:

ActiveWindow.DocumentMap = True
ActiveWindow.DocumentMap = False

lucas
08-25-2006, 11:25 AM
I think I misunderstood your question...

lucas
08-25-2006, 11:26 AM
I think undo is a tough one in VBA

fumei
08-28-2006, 02:41 PM
Huh? There is an Undo.Selection.TypeText Text:="Hello World"
ActiveDocument.Undowould type "Hello World", then remove that text.
Sub TestUndo()
ActiveDocument.Tables.Add Range:=Selection.Range, _
numrows:=3, numcolumns:=5
Selection.Tables(1).Cell(2, 2).Range.Text = _
"This is text in cell (2, 2)."
ActiveDocument.Undo
ActiveDocument.Undo
End Subwould make a table of 3 rows / 5 cols; put text into Cell( 2,2); then undo the text insertion; then undo the table insertion...leaving it exactly the way it was - no table, no text.

fumei
08-28-2006, 02:44 PM
Oh, and of course there is a:ActiveDocument.Redo

lucas
08-28-2006, 04:25 PM
Thanks Gerry.......

fumei
08-29-2006, 10:52 AM
This however, is not all that relevant to the original post.

Could you restate exactly what you want to do? The Document Map is a sort of autoformat thingie...

mansky
08-31-2006, 06:27 AM
Hi,
What I am trying to do is programmatically undo the AutoFormat-ing that is done when the property DocumentMap = True for a given document.

I'm thinking that the following code snippet would do the trick:

If (ActiveDocument.ActiveWindow.DocumentMap = True) Then
ActiveDocument.Undo
End If

Is the last line in the above If-block the correct statement to issue to Undo AutoFormat ?

And a related question: I understand that Command-Z pressed repeatedly, will go to the 3 most recently edited locations in the ActiveDocument. What object (ie. collection class I guess) are these locations stored in ? Can I get access to this object in VB ? And is the limit of 3 hard-coded, or can I change it?


Thanks!


Ed

fumei
08-31-2006, 08:59 AM
The Document Map is a strange beast. Invoking it causes AutoFormat. It is, in fact, an AutoFormat process. I found this out from macropod over at Tek-Tips - who knows a thing or two.

I am not sure it is in fact possible to truly "undo" the AutoFormat of Document Map.

Very good question re: the undo "collection"...I can't find it...yet there must be something!

TonyJollans
09-02-2006, 04:41 PM
What do you want to do?

Viewing the Document Map *may* trigger an AutoFormat (over which I don't think you have any control) and you can Undo it of you like, but if you do then you will lose the content of the map. Or you can clear the undo stack so that it can't be undone.

You can do Shift+F5 to goback to the last three edit points in a document but AFAIK you have no programmatic access to the undo stack.

fumei
09-03-2006, 11:28 AM
And I will have to agree with Tony. I have been seriously looking and I can not find any access to the undo stack at all. You can action it, but that is all.