Convert Doc Files to Docx in Bulk (by One Click) with VBA Code

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

Download VBA Code

Video Tutorial

Join Our Telegram Group techguruplus telegram group Join Our WhatsApp Group techguruplus whatsapp group
Nazim Khan - Author Image

Nazim Khan (Author) 📞 +91 9536250020
[MBA in Finance]

Nazim Khan is an expert in Microsoft Excel. He teaches people how to use it better. He has been doing this for more than ten years. He is running this website (TechGuruPlus.com) and a YouTube channel called "Business Excel" since 2016. He shares useful tips from his own experiences to help others improve their Excel skills and careers.

Leave a Comment