Batch Conversion From .doc to .docx?

R

RichD

Running Vista and just installed Office 2007 (Home and Student edition)

I have over 14,000 Word files in .doc format. Can I batch-convert them to
..docx format. It would be unrealistic to convert them one-by-one.
 
G

Graham Mayor

What would be the point of this exercise? Word 2007 will open Word doc
format without problem. Those documents that you need to update and change
you can do so when you need to update them. Having said that, the following
should save all the files in a selected folder as docx.

Sub SaveAllAsDOCX()
Dim strFileName As String
Dim strDocName As String
Dim strPath As String
Dim oDoc As Document

With Dialogs(wdDialogCopyFile)
If .Display <> 0 Then
strPath = .Directory
Else
MsgBox "Cancelled by User"
Exit Sub
End If
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

http://www.gmayor.com/installing_macro.htm
 
R

RichD

Thanks. I'm not familiar with using such info to make a Word macro but
appreciate the response anyway.

I thought Microsoft would have furnished a built-in converter to do the job,
since it wants its Office customers to use the new file format. Oh well...

One other question in this respect:

I used my normal.dot file from Office XP when I installed Office 2007 and it
works fine with Office 2007. Will the macros in the old normal.dot file that
I brought over work with the new .docx format?
 
G

Graham Mayor

The link I posted explains exactly what to do with the code.
http://www.gmayor.com/installing_macro.htm

As I said earlier Word 2007 opens and saves in doc format without the need
for conversion.

Word needs to create its own normal template (normal.dotm) into which you
can copy macros etc. It should do this during installation if another Word
version had been previously installed.

Most of the old macros should work, but there are some parts of the vba code
that have changed and some functions that are no longer available in the
same form.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
R

RichD

Graham:

You wrote something that may save me a good deal of time in terms of using
macros:

"Word needs to create its own normal template (normal.dotm) into which you
can copy macros etc. It should do this during installation if another Word
version had been previously installed."

Can you tell me how I could copy the contents of normal.dot to normal.dotm?
(Both are currently in the Templates folder.) I am now using normal.dot but I
want to somehow get its contents into normal.dotm because Word 2007 will not
permit me to build a new macro in normal.dot. and I need to add one or two
macros to the 25 or so I currently use.

Thanks.
 
G

Graham Mayor

Use the macro organizer (Development Tab > Macros > Organizer) to move macro
projects from one template to the other.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top