Solved

Batch Convert 2007 Word Douments to Templates

Posted on 2011-09-12
6
229 Views
Last Modified: 2012-08-14
Is there a easy way to convert 2007 Word Documents into Templates?
0
Comment
Question by:covxx
  • 3
  • 2
6 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 36524611
You could just rename them and move them to where you keep your templates.
0
 

Author Comment

by:covxx
ID: 36524708
I'm not a great office person could you expalin. What she has is a couple hundred Word doc's that people keep making changes to. I think that we will cut the problems down if they are turned into templates and when they go to save it will prompt them for a new file name. Thanks for your help!
0
 
LVL 31

Expert Comment

by:Helen_Feddema
ID: 36524953
Sounds like a good idea - but you need more than just saving them as templates, so after the conversion, check to see if they need any special features that are relevant to templates, have the right fonts and styles, etc.

Here is some code that will convert all the .doc files in a selected folder to .dot files (Word 97/2003 templates).  It is Word VBA, and requires a reference to the Scripting Runtime Library.

Public Sub ConvertDocsToTemplates()
'Created by Helen Feddema 12-Sep-2011
'Last modified by Helen Feddema 12-Sep-2011

On Error GoTo ErrorHandler

   Dim fld As Scripting.Folder
   Dim fil As Scripting.File
   Dim strFolder As String
   Dim fso As New Scripting.FileSystemObject
   Dim strFile As String
   Dim strFileAndPath As String
   Dim doc As Word.Document
   
   strFolder = "G:\Documents\Documents to Convert"
   Set fld = fso.GetFolder(strFolder)
   
   For Each fil In fld.Files
      strFile = fil.Name
      Debug.Print "File: " & strFile
      If Right(strFile, 3) = "doc" Then
         strFileAndPath = strFolder & "\" & strFile
         Set doc = Application.Documents.Open(strFileAndPath)
         doc.SaveAs2 FileName:="Test Doc.dot", _
            FileFormat:=wdFormatTemplate
         doc.Close
      End If
   Next fil
   
ErrorHandlerExit:
   Exit Sub

ErrorHandler:
   MsgBox "Error No: " & Err.Number _
      & " in ConvertDocsToTemplates procedure; " _
      & "Description: " & Err.Description
   Resume ErrorHandlerExit

End Sub

Open in new window

0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 31

Expert Comment

by:Helen_Feddema
ID: 36524979
I ran this code in Word 2010; for older versions of Word, use SaveAs instead of SaveAs2.
0
 
LVL 31

Accepted Solution

by:
Helen_Feddema earned 250 total points
ID: 36524995
I just realized that I have a hard-coded save name (that's the problem with recording macros!).  Here is is again:
Public Sub ConvertDocsToTemplates()
'Created by Helen Feddema 12-Sep-2011
'Last modified by Helen Feddema 12-Sep-2011

On Error GoTo ErrorHandler

   Dim fld As Scripting.Folder
   Dim fil As Scripting.File
   Dim strFolder As String
   Dim fso As New Scripting.FileSystemObject
   Dim strFile As String
   Dim strFileAndPath As String
   Dim doc As Word.Document
   Dim strSaveName As String
   
   strFolder = "G:\Documents\Documents to Convert"
   Set fld = fso.GetFolder(strFolder)
   
   For Each fil In fld.Files
      strFile = fil.Name
      Debug.Print "File: " & strFile
      If Right(strFile, 3) = "doc" Then
         strFileAndPath = strFolder & "\" & strFile
         Set doc = Application.Documents.Open(strFileAndPath)
         strSaveName = Left(strFile, Len(strFile) - 1) & "t"
         doc.SaveAs2 FileName:=strSaveName, _
            FileFormat:=wdFormatTemplate
         doc.Close
      End If
   Next fil
   
ErrorHandlerExit:
   Exit Sub

ErrorHandler:
   MsgBox "Error No: " & Err.Number _
      & " in ConvertDocsToTemplates procedure; " _
      & "Description: " & Err.Description
   Resume ErrorHandlerExit

End Sub

Open in new window

0
 

Author Closing Comment

by:covxx
ID: 36526599
Thank you very much!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Word 2007 formatting 13 45
Change management best practice 2 75
MS Word Formatting 3 25
Excel Spreadsheet in a Word 2016 document. 3 30
This is written from a 'VBA for MS Word' perspective, but I am sure it applies to most other MS Office components where VBA is used.  One thing that really bugs me is slow code, ESPECIALLY when it's mine!  In programming there are so many ways to…
PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now