Batch convert all old word format (.dot) files into new (.dotx) format

Is there a freeware tool (or built in word function) to select a folder and batch convert all .doc files into .dotx format files?
LVL 45
AndyAinscowFreelance programmer / ConsultantAsked:
Who is Participating?
 
GrahamSkanRetiredCommented:
That simplifies things
Sub ConvertTemplates()
    Dim doc As Word.Document
    Dim strInFolder As String
    Dim strOutFolder As String
    Dim strFileName As String
   
    strInFolder = "C:\MyFolder" 'edit this to your match your folder
    strOutFolder = "C:\MyNewFolder" 'and this folder
    strFileName = Dir$(strInFolder & "\*.doc") ' find the first file in the folder
     Do Until strFileName = ""
        Set doc = Documents.Open(strInFolder & "\" & strFileName)
        doc.SaveAs Replace(strFileName, ".doc", ".docx", , vbTextCompare), wdFormatXMLDocument
        doc.Close wdDoNotSaveChanges
        strFileName = Dir$()
    Loop
End Sub  

Open in new window

0
 
DansDadUKCommented:
Your question is slightly confusing.

.dot and .dotx files are template files.
.doc and .docx files are document files.

Your question title refers only to converting between the two template file extensions, but the question content refers to converting the old document file extension format to the new template file extension format.
0
 
GrahamSkanRetiredCommented:
This macro is intended to convert all the old format templates that don't have macros into the format for non-macro templates.

Sub ConvertTemplates()
    Dim doc As Word.Document
    Dim strInFolder As String
    Dim strOutFolder As String
    Dim strFileName As String
   
    strInFolder = "C:\MyFolder" 'edit this to your match your folder
    strOutFolder = "C:\MyNewFolder" 'and this folder
    strFileName = Dir$(strInFolder & "\*.dot") ' find the first file in the folder
     Do Until strFileName = ""
        Set doc = Documents.Open(strInFolder & "\" & strFileName)
        doc.SaveAs Replace(strFileName, ".dot", ".dotx", , vbTextCompare), wdFormatXMLTemplate
        doc.Close wdDoNotSaveChanges
        strFileName = Dir$()
    Loop
End Sub
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
AndyAinscowFreelance programmer / ConsultantAuthor Commented:
sorry - I meant doc and docx, it was a mistype.
I'll look at the code later.
0
 
AndyAinscowFreelance programmer / ConsultantAuthor Commented:
Sorry, I've been involved with some other things and it slipped off the radar.  I'll get back to this tomorrow.
0
 
AndyAinscowFreelance programmer / ConsultantAuthor Commented:
Thanks, it was a useful start with the SaveAs - I've had to expand it to copy with sub folders and documents already in the new (docx) format.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.