Question

Q: Is it possible to convert a batch of .doc files to .docx?

Hello,

 

we need to convert a number of .doc files to .docx to allow integration with a third party database. The only way we know how to do this is by opening each file individually in Word 2007 and saving it as a docx but we'd like something a bit faster - if there is another way?


bananasaregreen

Answer

A:

The short answer is no - but you can automate the process with a macro e.g. as follows. Note that the bridge used to post this message results in the doubling of periods that start the lines. When you paste into your vba editor you will have to remove those extra periods for the macro to work - http://www.gmayor.com/installing_macro.htm. Put all the documents that you wish to convert into a folder and run the macro. Select the folder you have used to store the documents. Note that the macro as written will not work with password protected documents.
 
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.SaveAs FileName:=strDocName, _
        FileFormat:=wdFormatDocumentDefault
    oDoc.Close SaveChanges:=wdDoNotSaveChanges
    strFilename = Dir$()
Wend
End Sub

--
<>>< ><<> ><<> <>>< ><<> <>>
Graham Mayor -  Word MVP
www.gmayor.com
Posted via the NNTP Bridge
<>>< ><<> ><<> <>>< ><<> <>>
"bananasaregreen" <=?utf-8?B?YmFuYW5hc2FyZWdyZWVu?=> wrote in message news:8f5549be-8143-4f0a-8f82-06c855fcb092...

Hello,

 

we need to convert a number of .doc files to .docx to allow integration with a third party database. The only way we know how to do this is by opening each file individually in Word 2007 and saving it as a docx but we'd like something a bit faster - if there is another way?


bananasaregreen

Graham Mayor - Word MVP - www.gmayor.com
Graham Mayor (Microsoft Word MVP)
For more Word tips and downloads visit my web site
http://www.gmayor.com/Word_pages.htm

Did this solve your problem?

Sorry this didn't help.

19 people were helped by this reply



 
Question Info

Views: 30,274 Last updated: June 13, 2018 Applies to: