Need help with macro....batch convert doc to docx including subfolders

Hello,

I searched the forums and was able to find the below macro to convert .doc to .docx (2010 format) which works perfectly in Word:

Sub SaveAllAsDOCX()
Dim strFilename As String
Dim strDocName As String
Dim strPath As String
Dim oDoc As Document
Dim fDialog As FileDialog
Dim intPos As Integer
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
With fDialog
    .Title = "Select folder and click OK"
    .AllowMultiSelect = False
    .InitialView = msoFileDialogViewList
    If .Show <> -1 Then
        MsgBox "Cancelled By User", , "List Folder Contents"
        Exit Sub
    End If
    strPath = fDialog.SelectedItems.Item(1)
    If Right(strPath, 1) <> "\" Then strPath = strPath + "\"
End With
If Documents.Count > 0 Then
    Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
If Left(strPath, 1) = Chr(34) Then
    strPath = Mid(strPath, 2, Len(strPath) - 2)
End If
strFilename = Dir$(strPath & "*.doc")
While Len(strFilename) <> 0
    Set oDoc = Documents.Open(strPath & strFilename)
    strDocName = ActiveDocument.FullName
    intPos = InStrRev(strDocName, ".")
    strDocName = Left(strDocName, intPos - 1)
    strDocName = strDocName & ".docx"
    oDoc.SaveAs2 FileName:=strDocName, _
        FileFormat:=wdFormatXMLDocument, _
        CompatibilityMode:=14
    oDoc.Close SaveChanges:=wdDoNotSaveChanges
    strFilename = Dir$()
Wend
End Sub

Can someone please modify the above macro to include subfolders or at least point me in the right direction? I have searched and have not been able to find a solution.

Thank you!

July 8th, 2013 5:44pm

Hello,

We have a bulk conversion utility that can convert multiple DOC files to DOCX files. Will you consider using it instead?

Blog article: Bulk Convert DOC to DOCX
http://blogs.msdn.com/b/ericwhite/archive/2008/09/19/bulk-convert-doc-to-docx.aspx 

With this utility, to make sure the documents in all subfolders are also dealt with, use the ConvertSubFolders setting.

For example, add the following line to the [FoldersToConvert] section:

ConvertSubFolders=1

Free Windows Admin Tool Kit Click here and download it now
July 10th, 2013 4:21am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics