Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking the undo buffer 1

Status
Not open for further replies.

eman6

Programmer
Dec 7, 2004
578
0
0
CH
I would like to be able to check the undo buffer contents at the beginning of a VBA macro.
Is there a way?

The purpose is to avoid the prompt:
"Do you want to save the changes to the document?"

When no changes have taken place at all.


_______________________________________

Eman_2005
Technical Communicator
 
Which application ?
If Word you may consider the Document.Saved property
If Excel: Workbook.Saved

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
AFAIK you cannot access the Undo buffer. If I understand you correctly, you're trying to avoid the save alert in cases where a change was made then the user selected Undo; Excel sees this as a change and ask whether to save, but as far the user is concerned no data/information change actually occurred. Is that correct? If so, you'd have to go to great lengths to detect this condition (i.e. maintin a copy of all data to compare against when workbook was closed). I'm not sure it would be worth it. If you simply want to supress all save prompts, then PHV's suggestion will do the trick (e.g. In Excel: ThisWorkbook.Saved = True).


Regards,
Mike
 
You may also consider the Application.DisplayAlerts property (both word and excel).

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
The problem is as follows:
Word 2000
I have an autoclose macro that checks document properties.
In case some values where missing, it prompts the user to enter them.
Now even if nothing is missing and the user just opened the document and did nothing, when closing the document, we get this prompt "Do you want to save....etc"
So it looks like the mere fact that the macro is checking on some doc properties, is considered a change :-(
I tried to put at the beginning of the autoclose:
<Code>
Dim myDocIsSaved as boolean
If activedocument.Saved = true then
myDocIsSaved = True
Else
myDocIsSaved = False
End if
</code>
and at the end of the autoclose:
<Code>
if myDocSaved = True Then
ActiveDocument.UndoClear
End if
</code>
But it did not work :-(


_______________________________________

Eman_2005
Technical Communicator
 
You try something like this (in your AutoClose proc):
Dim myDocIsSaved As Boolean
myDocIsSaved = ActiveDocument.Saved
' your code to check missing info
' if some were missing then set myDocIsSaved to false
ActiveDocument.Saved = myDocIsSaved

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
On a similar topic to this, I have had a few questions about the undo command. A few times, I have made some changes (that could have been undone before running a macro), run a macro (a sub, really), and then realized that I wanted to change that first bit of data. However, I've noticed that you can undo no changes before a macro runs.

I've also wondered if there was a way to to add an undo command. For instance, say I have a macro that changes the number in Range("A1") to its negative. Is there a way to specify a macro to run to undo that operation? I don't have any specific examples of code I'm trying to write, but I was just wondering if anyone had any thoughts.

Thanks for any info,
Joseph
 
Hey, thanks. The arcicle looked like it had some very promising information

Joseph.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top