PDA

View Full Version : Avoid 'Do you want to save?" prompt when track changes is active?



DaVinney
03-14-2011, 06:44 PM
I have a macro that makes batch revisions to multiple documents, then saves them before closing. I added a user-option to track the revisions if so desired. If the 'track changes' option is NOT selected by user, the documents open/save/close with no prompts. But if 'track changes' is on, Word stops at each doc and prompts whether the user is sure the change tracking should be saved.

Presently, I'm using:


oDoc.Close SaveChanges:=wdSaveChanges

Question: Is there something I can add to avoid the unwanted save prompt?

Frosty
03-15-2011, 08:10 AM
You have to make sure you actually save the document if you use the .Saved property, but...

What about the following:

oDoc.Save
oDoc.Saved = True '(this flags it as not needing to ask the user about prompting-- not sure how that works with track changes as well, but I would think it would allow you to close without a prompt)
oDoc.Close

At the very least, you can put a breakpoint on oDoc.Close and then check to see if the .Saved property of the document is true.

DaVinney
03-15-2011, 09:37 AM
Frosty, thanks for the suggestion.

I tried it, but no joy. The unwanted track changes prompt still appears.

Frosty
03-15-2011, 09:53 AM
I get confused on the versions... in Word 2003 I had, at one point, programmed a confirmation box for my end-users to warn them that track changes was on when they open a document. But there may be some sort of Word setting which warns the user before saving a document if track changes is turned on in the document.

Is it possible you have another addin which checks to see if track changes is on?

If, as I understand it, you are turning on track changes for the purpose of showing the changes you are making during your processing... why don't you try turning it back off before you close the document? As long as you don't do something which accepts all changes, your end-users should still be able to open the document and see whatever revisions you have made. (Caveat: as long as they have the settings to "Show final with mark up" is turned on... remember, whether or not changes are shown is a user setting, not a document setting... the document setting is whether track changes is actually on... but how it is displayed is a function of the end-user's word session).

Let me know if this still isn't enough, and I will investigate a bit more when I have a moment. Also-- if you aren't able to resolve, let me know what version of Word you're working with. And double-check that you don't have any other addins creating this behavior.

I *think* you should be able to get away with turning the track changes back off before you close the document and still get what I think you want.

DaVinney
03-15-2011, 10:39 AM
The exact pop-up message is:

The document being saved contains tracked changes.
Continue with save? |OK| |Cancel|


I'm using Word 2007.

I have no add-in that checks if track changes is on.

I typically have routines save any settings in the document I need to alter, then restore them before exit. So, track changes is turned back off before saving in this case as well, since my test documents have that setting off when the docs open. Yet I'm still getting the prompt. If user has 50 documents revised, the prompt must be answered 50 times :doh:

Thanks again for the help.

DaVinney
03-25-2011, 05:22 PM
(bumping this back up in hopes of an answer/ideas)

I'd also be interested in any trickery someone could think of to avoid the unwanted prompt. It really puts the brakes on what is supposed to be a hands-free time-saving routine.

Thanks.

DaVinney
03-25-2011, 07:19 PM
I found this on Shauna Kelley's site (I guess it's a user-setting I suppose can't be modified via code):

http://www.shaunakelly.com/word/sharing/howtrackchangesworks.html



Word 2007 and Word 2010: In Word 2007 start with the round Office button > Word Options. In Word 2010 start with File > Options. In both versions, from the Word Options dialog, choose Trust Centre > Trust Centre Settings > Privacy Options. In the "Document-specific settings" section, tick the box "Warn before printing, saving or sending a file that contains tracked changes or comments".

Frosty
04-07-2011, 03:31 PM
I'm not a group policy expert, but if all you needed to do was turn off that setting, and your code is working fine... then you're done. Otherwise, try reading the following:
http://technet.microsoft.com/en-us/library/cc179123.aspx#privacyoptions

And from there, you could talk to someone at your organization who understands group policies, and potentially set up a way of either a) having a UID with a different policy than you might want for the typical end-user or b) look at adjusting this policy on a particular machine.

Basically-- just because you can't get to it through VBA doesn't mean there aren't ways of having this setting be set the way you want it.

Alternatively, you could certainly put a pop-up messagebox at the beginning of the routine asking the user if he/she has "unchecked the warn before printing, saving or sending a file that contains tracked changes or comments" before proceeding, and if the answer is vbno... exit your routine. A good reminder with the info right there.

Just a few thoughts. Sorry for the delay in response.

DaVinney
04-07-2011, 05:05 PM
There are many levels of network admin in my org...and I now avoid them all as much as possible.

I inquired about adjusting the Trust Center before and that went fubar real quick :p

Thanks for the suggestions, Frosty. I'm leaning towards the idea of just warning the end-user with a message.

Frosty
04-07-2011, 05:15 PM
Ah, yes... that could be problematic. However, if they are actively setting this setting via group policy, you could be fubar as well (as you will be able to warn the end-user, but they won't be able to adjust the setting).

If that happens, you may either have to a) remove the option for the user to track changes or b) come up with your own "track changes" feature (maybe inserting the text, formatting it as blue and double-underlined with a bookmark around it...and then have an additional function which goes through all of those bookmarks and takes away the double-underline/blue formatting)... at least, if the purpose is to review the changes.

Another brainstorm: you could spit out a second document which contains a legal blackline of the before and after... that would give you the ability to review what was done but not circumvent some privacy options your company is setting.

It's obviously very complex... if you need additional brainstorms, feel free to revive the thread.

DaVinney
04-07-2011, 06:42 PM
I've confirmed that, fortunately, users CAN change that particular setting, so I just need to tell them with a msg where the checkbox is buried in the Word Options.

Guess that's it for this thread. Thanks for all the help :hi:

macropod
04-07-2011, 07:17 PM
You could use Sendkeys to toggle the warning on/off:
SendKeys "%fit{TAB}t{TAB}p{ENTER}{ESC}"
but the problem is that there doesn't seem to be a way to check its current state. A possible workaround would be to set a timer before each:
oDoc.Close SaveChanges:=wdSaveChanges
call and, if the delay is more than a specified amount (eg 2 seconds), indicating that the user had to intervene, call the SendKeys routine. This should mean the warning would only get generated once per 'session'. You might also want to set a flag to tell Word whether to re-run the SendKeys routine when it finishes processing. There'll be a bit of screen flickering each time, and this seems to be unavoidable.

Viggo_L
03-22-2013, 06:34 AM
I hope it is OK to revive this old post! I am having the exact same problem with the dialog box "..continue with save?"
I use the "save" in the end of macro that turns on password protection.

Problem is that I am in an environment where we users can not make changes to the Trust Center. So no easy fix.

I see 2 options:
1) VBA to accept the presence of the Tracked changes

2) Change the default from "Cancel" to "OK". Not very elegant but would allow hitting enter in one go.
I have no idea have to access the coding behind the dialog box.

Any good ideas?

macropod
03-22-2013, 08:00 AM
What kind of password protection (eg read-only, tracked changes, comments, filling in forms)? Are you saving after you enable the protection?

Viggo_L
03-22-2013, 09:04 AM
Primarily Read Only.
Secondarily Track changes allowed.
No exceptions in terms of specific user rights.

Thanks

macropod
03-23-2013, 12:04 AM
Try switching off the alerts, thus:
Options.WarnBeforeSavingPrintingSendingMarkup = False
.Save
Options.WarnBeforeSavingPrintingSendingMarkup = True

Viggo_L
03-24-2013, 03:07 AM
Thank you, Paul! It works perfectly fine.
I am using:

Options.WarnBeforeSavingPrintingSendingMarkup = False
ActiveDocument.Save

I was not sure about the purpose of your second line of code (example maybe?).

Thanks again.

macropod
03-24-2013, 05:01 AM
The snippet I posted assumed your 'save' method was embedded in a larger block of code that defined the document to be processed, in which case, you wouldn't insert 'ActiveDocument' at this point.

I also note that you've omitted the third code line. Doing so means the default option to warn users about tracked changes, etc before printing or saving a document won't occur. Since having that option active is evidently part of your setup (which is why you were getting the messages in the first place), it should be restored.

Viggo_L
03-24-2013, 01:11 PM
Thanks a lot for the details. I probably didnt explain the background well enough.
When my team prepares a document and send it for external review we have to apply password protection.
I have compiled (from the web) a macro to do that, and since it is the last step, I also wanted to save it in the process.
Because it is part of a review process, and I am aware of contained TC, my wish was to have the Save step made smooth. Therefore I wanted to avoid the warning.
The code I use now looks like this:

If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect wdAllowOnlyReading, _
NoReset:=True, _
Password:="password"
Else
MsgBox "Already locked"
End If
Options.WarnBeforeSavingPrintingSendingMarkup = False
ActiveDocument.Save
End Sub

At the moment it seems to be doing what I want, pls correct me if I have misunderstood it.

macropod
03-24-2013, 01:29 PM
The point I was making is that you should have:
Options.WarnBeforeSavingPrintingSendingMarkup = True
before exiting the sub, so that the option is re-set to its normal state for other documents. This setting applies to Word generally, not just to the document in question.

macropod
03-24-2013, 09:13 PM
Actually, if the document is being provided to others who may run the macro, it is important that you restore their system's options to whatever state you found it, thus:
Dim bOpt As Boolean, StrPwd As String
StrPwd = "password"
bOpt = Options.WarnBeforeSavingPrintingSendingMarkup
With ActiveDocument
If .ProtectionType = wdNoProtection Then
.Protect wdAllowOnlyReading, NoReset:=True, Password:=StrPwd
Else
MsgBox "Already locked"
End If
Options.WarnBeforeSavingPrintingSendingMarkup = False
.Save
End With
Options.WarnBeforeSavingPrintingSendingMarkup = bOpt

Viggo_L
03-24-2013, 10:43 PM
Ahh, I get your point!
Thanks for the help.

Viggo_L
03-25-2013, 12:56 AM
Besides, I have noticed that Track Changes is being turned off when protecting, both when using the code and manually.

Is that normal and something Word users have to live with?
(I dont understand that I havent noticed it before...)

Thanks for the improved code above!

macropod
03-25-2013, 02:44 AM
True, you can't have change-tracking and forms protection. But then, in post #15 you didn't mention change-tracking and I didn't give it any thought when writing post #21.