Solved

Batch Convert 2007 Word Douments to Templates

Posted on 2011-09-12
6
235 Views
Last Modified: 2012-08-14
Is there a easy way to convert 2007 Word Documents into Templates?
0
Comment
Question by:covxx
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

 
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PaperPort is a popular document imaging/management product from Nuance Communications (http://www.nuance.com/). It is in widespread use by both individuals (http://www.nuance.com/for-individuals/by-product/paperport/index.htm) and businesses (http:/…
This article provides the solution to a question (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28674207.html) posed here at Experts Exchange. The asker of the question has many JPG images in many folders, and all of t…
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

739 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