PDA

View Full Version : DisplayAlerts=False not working with SaveAs and a file containing comments ??



RobVos
06-14-2011, 10:20 AM
Why does this not work? When this code runs, I still get the warning that the document being saved contains comments and it asks if I want to continue or cancel. I do not want this.

Application.DisplayAlerts = False
'Set path for saving
strPath = ActiveDocument.AttachedTemplate.Path & "\"
'Name the Spec file and save it
strSpecName = strPath & strWI & "_" & cboCategory.Value & "_" & txtWI.Value
ActiveDocument.SaveAs Filename:=strSpecName, FileFormat:=wdFormatXMLDocumentMacroEnabled
Application.DisplayAlerts = True

I do not want the user to click cancel if this warning appears. I also tried using Application.DisplayAlerts = wdAlertsNone But same results. How can I stop this alert?

Frosty
06-14-2011, 03:49 PM
I believe it depends on what version of office you're using... but with that code, it looks like you're in 2007/2010.

You can't programmatically turn off some of the "protect me from myself by making sure I know about metadata in the document" features.

There are some reasons for this which is a longer discussion. But for the purposes of your question, I think the reason is because you simply can't do that.

You also can't disable the warning about a file containing tracked changes, to my knowledge.

There was a thread on this recently, and it seemed that it was a design decision by Microsoft in 2007/2010 to disallow this kind of functionality (whereas in 2003 I could disable the warning).

EDIT: I forgot to answer your question. It depends on 2007 or 2010, but it's in the Trust Center area of the application and you can turn off the warn users about comments/track changes/etc before saving/sending as email. But you have to do it through group policy or manually unchecking box, not through code.

RobVos
06-15-2011, 03:58 AM
Frosty, thanks for the information. I am using 2007. I see the checkbox in the Trust Center. It appears I am going to have to try and live with this warning.