Skip to content

Instantly share code, notes, and snippets.

@statgeek
Created July 10, 2017 16:21
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save statgeek/c7cab12c48133abefc2b4c84f264b290 to your computer and use it in GitHub Desktop.
Save statgeek/c7cab12c48133abefc2b4c84f264b290 to your computer and use it in GitHub Desktop.
VBS Script - convert Doc to DOCX file
bRecursive = False
sFolder = "C:\_localdata\temp\Test"
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oWord = CreateObject("Word.Application")
oWord.Visible = True
Set oFolder = oFSO.GetFolder(sFolder)
ConvertFolder(oFolder)
oWord.Quit
Sub ConvertFolder(oFldr)
For Each oFile In oFldr.Files
If LCase(oFSO.GetExtensionName(oFile.Name)) = "doc" Then
Set oDoc = oWord.Documents.Open(oFile.path)
oWord.ActiveDocument.SaveAs oFile.path & "x", 12
oDoc.Close
End If
Next
If bRecursive Then
For Each oSubfolder In oFldr.Subfolders
ConvertFolder oSubfolder
Next
End If
End Sub
@awise777
Copy link

awise777 commented Jan 9, 2021

Thanks for sharing. Turns out I didn't have a microsoft word installed, so I had to use this tool for converting doc to docx: https://freetools.site/document-converters/doc-to-docx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment