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 46
AndyAinscowFreelance programmer / ConsultantAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
AndyAinscowFreelance programmer / ConsultantAuthor Commented:
sorry - I meant doc and docx, it was a mistype.
I'll look at the code later.
0
OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Word

From novice to tech pro — start learning today.