Fancy Notes

Convert Doc to Docx

Step-by-Step Guide

In this section, we’ll show you how to use VBA code to batch convert .doc files to .docx files in a specific folder. Just follow the steps below:

Gather your files

Gather all the .doc files that you want to convert into a single folder.

Open Word and VBA Editor

Open Microsoft Word, and press Alt + F11 to open the Microsoft Visual Basic for Applications (VBA) window.

Insert the VBA script

In the VBA window, click Insert > Module. Then, copy and paste the following VBA code into the module:

Sub ConvertDocToDocx()
'Updated by ExtendOffice 20181128
  Dim xDlg As FileDialog
  Dim xFolder As Variant
  Dim xFileName As String
  Application.ScreenUpdating = False
  Set xDlg = Application.FileDialog(msoFileDialogFolderPicker)
  If xDlg.Show <> -1 Then Exit Sub
  xFolder = xDlg.SelectedItems(1) + "\"
  xFileName = Dir(xFolder & "*.doc", vbNormal)
  While xFileName <> ""
    Documents.Open FileName:=xFolder & xFileName, _
      ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, _
      PasswordDocument:="", PasswordTemplate:="", Revert:=False, _
      WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _
      wdOpenFormatAuto, XMLTransform:=""
    ActiveDocument.SaveAs xFolder & Replace(xFileName, "doc", "docx"), wdFormatDocumentDefault
    ActiveDocument.Close
    xFileName = Dir()
  Wend
  Application.ScreenUpdating = True
End Sub
VBA Code

Run the script

Press the F5 key to run the code. In the window that appears, select the folder containing your .doc files and click OK. The script will automatically convert all .doc files to .docx format.

Select Folder

Resources

  1. Batch Convert DOC to DOCX with VBA – ExtendOffice

On this page