Modifying a document without undo

Started by Nikolay, September 14, 2014, 04:39:50 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Nikolay

Hi guys, a following question

Is it possible to modify a Visio document (programmatically) without changes appearing undo "Undo"?
I.e. tell Visio something like "don't add these modifications to the undo list".

Like turning off the undo manager temporarily and then turning it on again (without loosing the user undo list)

If you set Application.EnableUndo = false, the undo list will be reset. That's not what I want.
Wrapping actions in a single undo scope also does not help much, as I don't want my undo scope to be visible in the undo list at all.

JuneTheSecond

No answer?
May be, you wish feature request to enhance undo manager.
Best Regards,

Junichi Yoda
http://june.minibird.jp/


wapperdude

It's not anything I ever had to deal with.   ???

Wapperdude
Visio 2019 Pro

Nikolay

A partial solution.. does not solve the initial issue, but at least something :)

If you write to Document.SolutionXMLElement then this action is not included in the undo, which is great.

JuneTheSecond

Nikolay, would you please let me know more how you are trying?
Best Regards,

Junichi Yoda
http://june.minibird.jp/

AndyW

That is a lot to ask of any transaction journalling system!

If you could turn it off and back on, you may be sure your intermediate changes will not affect anything already in the undo list, but that would be impossible for Visio to know. For example, what if while it was off you deleted a shape that had been moved. Turning it back on and then doing an undo on a shape that no longer exists.

I have had to accept in my application. Changes that are not the result of a user action, e.g. timers for example, I have had to purge the undo list as these actions can't be undone.

Live with how it works, if you try to fiddle around it, it will only bite you later on. It is hard to complain about Visio, there isn't much that you can't do and nothing out there comes anywhere close to it. I should know as my application pushes the boundaries of its capabilities.
Live life with an open mind

Nikolay

#7
Thanks Andy, makes perfect sense!

My issue is that on opening diagram the app updates the diagram, and this action drops into undo list,
i.e. you've just opened a diagram and already have 1 undo action, which might be confusing.

Note that at this moment there is nothing till now in the undo queue for this document (it is just being opened), so the previous commands are not affected.
Also there are commands which do not affect others at all (that is, "I" know they won't), like modifying something in document shapesheet.

So I thought it could be possible to prevent undo just for these ones (i.e. just to tell Visio not to put those to the UNDO stack)
In the case you describe, like "skipping" DELETE command, whereas in the undo stack there is "MOVE", it could just fail with error, I wouldn't mind.

But you are completely right, it looks like a generic solution to that from the Visio point of view might easily become a nightmare :)

Paul Herber

Once the update has finished you could set the undo count to 0, then reset it back to its original value. That will clear the undo queue.
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

Nikolay

#9
That's right, but this will reset undo not only for the current document, all previous undo history also (i.e. also for other documents).
I.e. when I open a document from another document, and update the second one with resetting the undo count, the undo history for the first one will be reset.
That is, Visio has only undo queue, common for all documents..

Paul Herber

Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

Visio Guy

On a related note, there is a Document.Saved property, otherwise known as the "dirty flag".

I think the idea is to set .Saved = True to make Visio think that you haven't done anything, even though your code has altered the drawing. If the user closes the document, there won't be a prompt to save changes, but the alterations will also not be saved.
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

Nikolay

Yep, this is done already..
That is, Document.Saved = true is already set.
But it does not always help against some curious users asking why undo is enabled whereas they haven't done anything actually, and what are those funny entries in the undo list exactly?? Or why the undo is disabled?? :)

AndyW

My users have had to live with the fact that sometimes they can undo and other times not. Although curiously sometimes Visio (2010) stops letting you undo and is only sorted by restarting visio, not been able to repeat that reliably.
Live life with an open mind