Editing a Word Macro
Posted on 2013-01-02
I've found a Word macro to batch-convert Microsoft Works (.wps) files to Word 97 (.doc). However, I need a way to convert .wps to Word 2007 (.docx). Because there are many files (more than a thousand) and they are distributed among dozens, or hundreds, of folders, it isn't practical for me to consolidate them into a single folder, process them, and then redistribute them to their correct folders. If you can edit the following macro, such that it converts the files to .docx in Word 2007 format, that would resolve my dilemma.
Dim bConv As Boolean
Dim strFileName As String
Dim strDocName As String
Dim strPath As String
Dim oDoc As Document
Dim Response As Long
Dim fDialog As FileDialog
bConv = Options.ConfirmConversions
Options.ConfirmConversions = False
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
.Title = "Select folder and click OK"
.AllowMultiSelect = False
.InitialView = msoFileDialogViewList
If .Show <> -1 Then
MsgBox "Cancelled By User", , "Save all as DOC"
strPath = fDialog.SelectedItems.Item(1)
If Right(strPath, 1) <> "\" Then strPath = strPath + "\"
If Documents.Count > 0 Then
strFileName = Dir$(strPath & "*.wps")
While Len(strFileName) <> 0
Set oDoc = Documents.Open(strPath & strFileName)
strDocName = ActiveDocument.FullName
intPos = InStrRev(strDocName, ".")
strDocName = Left(strDocName, intPos - 1)
strDocName = strDocName & ".doc"
oDoc.SaveAs FileName:=strDocName, _
strFileName = Dir$()
Options.ConfirmConversions = bConv