问题
There's a check box "Maintain compatibility with previous versions of Word" in "SaveAs" dialogue box, by recording a macro and have the check box ticked, I got
ActiveDocument.SaveAs2 FileName:= _
"C:\Users\jondoe\123.dotm", _
FileFormat:=wdFormatXMLTemplateMacroEnabled, LockComments:=False, _
Password:="", AddToRecentFiles:=True, WritePassword:="", _
ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False, CompatibilityMode:=12
tick it off, the only difference is
CompatibilityMode:=15
according to WdCompatibilityMode Enumeration, 12 stands for Word2007, 15 for Word2013.
But when I run the exact code in VBA, put it in
Public Sub App_DocumentBeforeSave(ByVal Doc As Document, SaveAsUI As Boolean, Cancel As Boolean)
the sub get called before word showing the save as dialogue, but no matter I set Compatibility to 12 or 15, the check box is not checked.Is it possible to check it via VBA? If not, I have to withdraw my theory "everything can be done manually can be done programmatically".
Any ideas?
And, when you do the save as manually, seems the status of that check box come form last save as action,
回答1:
This MSDN page discusses the related SetCompatibilityMode
command, which looks like what you want.
ActiveDocument.SetCompatibilityMode (wdWord2003)
It's not tied to the Save, which seems like it will work better for you.
来源:https://stackoverflow.com/questions/32237729/ms-word-saveas-check-maintain-compatibility-via-vba