Save .doc file as .docx file with VBA to remove compatibility flag.

G

Greg Maxey

I am trying to convert a batch of .doc files to .docx files using VBA. I
have managed to "physically" convert the files, but all files converted
retain the [Compatibility flag].

I recorded two macros of the process of using the FileSaveAs command to
save two .doc documents as .docx documents. With one I selected to maintain
compatibily. The file was saved in the .docx format with the compatibility
flag. With the other I unchecked the option to maintain compatibility and
the file was saved as a .docx file without the compatibility flag.

The recorded results show no difference:

Sub Macro1()
ActiveDocument.SaveAs FileName:="Test Doc 1.docx", FileFormat:= _
wdFormatXMLDocument, LockComments:=False, Password:="", AddToRecentFiles
_
:=True, WritePassword:="", ReadOnlyRecommended:=False,
EmbedTrueTypeFonts _
:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
End Sub

Sub Macro(2)
ActiveDocument.SaveAs FileName:="Test Doc 2.docx", FileFormat:= _
wdFormatXMLDocument, LockComments:=False, Password:="", AddToRecentFiles
_
:=True, WritePassword:="", ReadOnlyRecommended:=False,
EmbedTrueTypeFonts _
:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
End Sub

How to save a .doc to .docx using VBA and remove the compatibility flag.

Thanks.
 
G

Greg Maxey

Stumbled on the answer:

Sub Macro1()
ActiveDocument.SaveAs FileName:="Test Doc 1.docx", FileFormat:= _
wdFormatXMLDocument, LockComments:=False, Password:="",
AddToRecentFiles _
:=True, WritePassword:="", ReadOnlyRecommended:=False,
EmbedTrueTypeFonts _
:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
ActiveDocument.Convert 'Added this line.
End Sub


Greg said:
I am trying to convert a batch of .doc files to .docx files using
VBA. I have managed to "physically" convert the files, but all files
converted retain the [Compatibility flag].

I recorded two macros of the process of using the FileSaveAs command
to save two .doc documents as .docx documents. With one I selected
to maintain compatibily. The file was saved in the .docx format with
the compatibility flag. With the other I unchecked the option to
maintain compatibility and the file was saved as a .docx file without
the compatibility flag.
The recorded results show no difference:

Sub Macro1()
ActiveDocument.SaveAs FileName:="Test Doc 1.docx", FileFormat:= _
wdFormatXMLDocument, LockComments:=False, Password:="",
AddToRecentFiles _
:=True, WritePassword:="", ReadOnlyRecommended:=False,
EmbedTrueTypeFonts _
:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
End Sub

Sub Macro(2)
ActiveDocument.SaveAs FileName:="Test Doc 2.docx", FileFormat:= _
wdFormatXMLDocument, LockComments:=False, Password:="",
AddToRecentFiles _
:=True, WritePassword:="", ReadOnlyRecommended:=False,
EmbedTrueTypeFonts _
:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
End Sub

How to save a .doc to .docx using VBA and remove the compatibility
flag.
Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top