Solved

Batch Convert 2007 Word Douments to Templates

Posted on 2011-09-12
6
236 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

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!

Question has a verified solution.

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

Microsoft Word is a program we have all encountered at some point, but very few of us have dug deep into its full scope of features, let alone customized it to suit our needs. Luckily making the ribbon (aka toolbar, first introduced in Word 2007) wo…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
We often encounter PDF files that are pure images, that is, they do not have text characters, but instead contain only raster graphics. The most common causes of this are document scanning software and faxing software/services that create image-only…

705 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