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

Join the TechGuruPlus Telegram group

Join Our WhatsApp Group

Join the TechGuruPlus WhatsApp group
Nazim Khan, founder of TechGuruPlus.com

— Founder & Editor, TechGuruPlus.com
[MBA in Finance]

Nazim Khan has spent over ten years working with Excel, Tally and office documentation in accounts, finance and MIS roles. He has been running TechGuruPlus.com since 2016, where he publishes free editable templates for office work, and the YouTube channel Business Excel. He has trained more than 50,000 people online. Every template on this site is built and checked by him before it is published.

Contact  Â·  Excel Course

Leave a Comment