Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-03-2012, 07:49 AM
ohmzoned ohmzoned is offline Attach a template to 1000+ documents Windows XP Attach a template to 1000+ documents Office 2007
Novice
Attach a template to 1000+ documents
 
Join Date: Feb 2012
Posts: 1
ohmzoned is on a distinguished road
Question Attach a template to 1000+ documents

Hi everyone,

I have almost 1000 documents that have a template attached to them. The template has recently been updated so now whenever we open the documents, it says "your template needs to be updated." This is part of our coding, so I expect to see this warning. You click "ok" and then save your document, and now your template is updated.

I was wondering if there is a way to remove the old template and then apply the new one to all 1000 documents without going 1 by 1. The actual template file is the same name, but has been updated (file.dot). We are running Office 2007 - the files are technically stored on a SharePoint, but I can extract them\upload new ones as needed.

Thanks much!!
Reply With Quote
  #2  
Old 02-04-2012, 12:09 AM
macropod's Avatar
macropod macropod is offline Attach a template to 1000+ documents Windows 7 64bit Attach a template to 1000+ documents Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi ohmzoned,

Assuming all files in a given folder should have the same template, try:
Code:
Sub AttachNewTemplate()
Application.ScreenUpdating = False
Dim strFolder As String, strTmplt As String, strFile As String, wdDoc As Document
With Application.FileDialog(msoFileDialogFilePicker)
  .Filters.Clear
  .AllowMultiSelect = False
  .Filters.Add "All Word Templates", "*.dot; *.dotx; *.dotm", 1
  If .Show = -1 Then
    strTmplt = .SelectedItems(1)
  Else
    Exit Sub
  End If
End With
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.doc", vbNormal)
' Create a temporary Word session to do the processing
Dim wdTmp As New Word.Application
wdTmp.Visible = False
'wdTmp.DisplayAlerts = wdAlertsNone
While strFile <> ""
  Set wdDoc = wdTmp.Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
  wdDoc.AttachedTemplate = strTmplt
  wdDoc.Close SaveChanges:=True
  strFile = Dir()
Wend
Set wdDoc = Nothing: Set wdTmp = Nothing
Application.ScreenUpdating = True
End Sub
 
Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function
When you run the code, simply select the template, then the folder containing the files to process. If you are getting unnecessary prompts as files are opened, try uncommenting the 'wdTmp.DisplayAlerts = wdAlertsNone' line. it may (or may not) kill the prompts. Don't do this if the files are mailmerge main documents, though, or they'll lose their data connections.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
templates, word 2007

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Attach a template to 1000+ documents Outlook 2003 event ID 1000 djsep3763 Outlook 1 03-18-2012 06:06 PM
How to attach an action to a hyperlink tapty PowerPoint 0 01-27-2012 05:25 AM
Attach a template to 1000+ documents Template with automatic text input from seperate documents! word Word 1 06-03-2011 02:45 PM
Avery Labels Numbered 1 through 1000+? kteh54 Word 0 03-03-2010 06:06 PM
Template "File In Use" when opening 2 documents based on the same template wendt Word 5 12-15-2009 12:37 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:26 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft