Created
July 10, 2017 16:21
-
-
Save statgeek/c7cab12c48133abefc2b4c84f264b290 to your computer and use it in GitHub Desktop.
VBS Script - convert Doc to DOCX file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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