If you have a large number of old Microsoft Word .doc files and want to convert them into the modern .docx format without opening and saving each file manually, this VBA macro can save a lot of time.
The code automatically scans a selected folder, opens every .doc file, applies Word’s full compatibility conversion, refreshes document formatting, and then saves each file as a proper .docx document in a separate output folder.
This process helps ensure that converted files are fully compatible with newer versions of Microsoft Word while preserving formatting, layouts, and document structure.
It is especially useful for offices, businesses, and users who need to bulk-convert hundreds or even thousands of legacy Word documents with a single click.
VBA Code:
Sub ConvertDOCtoDOCX_Proper()
Dim sourceFolder As String
Dim targetFolder As String
Dim fileName As String
Dim doc As Document
Dim newName As String
sourceFolder = "D:\MyDocFile\"
targetFolder = "D:\NewDocxFile\"
If Dir(targetFolder, vbDirectory) = "" Then MkDir targetFolder
Application.ScreenUpdating = False
Application.DisplayAlerts = wdAlertsNone
fileName = Dir(sourceFolder & "*.doc")
Do While fileName <> ""
' ?? Open in normal mode (IMPORTANT)
Set doc = Documents.Open( _
fileName:=sourceFolder & fileName, _
ConfirmConversions:=False, _
ReadOnly:=False, _
AddToRecentFiles:=False)
' ?? FORCE full compatibility conversion (MOST IMPORTANT)
If doc.CompatibilityMode <> wdCurrent Then
doc.Convert
End If
' ?? Force repagination (printer metrics refresh)
doc.Repaginate
' ?? New filename
newName = targetFolder & Replace(fileName, ".doc", ".docx")
' ?? Save as proper DOCX
doc.SaveAs2 _
fileName:=newName, _
FileFormat:=wdFormatXMLDocument, _
AddToRecentFiles:=False
doc.Close SaveChanges:=False
fileName = Dir
Loop
Application.DisplayAlerts = wdAlertsAll
Application.ScreenUpdating = True
MsgBox "All files converted with full compatibility fix!", vbInformation
End Sub



