Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-01-2017, 07:23 PM
macropod's Avatar
macropod macropod is offline Moving body text from old files to new files (based on template) Windows 7 64bit Moving body text from old files to new files (based on template) Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,521
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


In reality, all you should need to do is attach the new template to the existing files (or copies of them), then apply the new Style definitions to the documents you've attached the template to. For example, the following macro does that for all documents in a selected folder:
Code:
Sub UpdateDocumentTemplates()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, strDocNm As String, wdDoc As Document
strDocNm = ActiveDocument.FullName
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.doc", vbNormal)
While strFile <> ""
  If strFolder & "\" & strFile <> strDocNm Then
    Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
    With wdDoc
      .AttachedTemplate = "C:\Templates\SomeTemplate.dotm"
      .CopyStylesFromTemplate (.AttachedTemplate.FullName)
      .Close SaveChanges:=True
    End With
  End If
  strFile = Dir()
Wend
Set wdDoc = 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
Simply change "C:\Templates\SomeTemplate.dotm" to suit your requirements.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to find/replace text in many word files - but text is in embedded word files semple.13 Word VBA 5 11-03-2015 01:20 PM
Moving body text from old files to new files (based on template) Moving Multiple Hyperlinked Files around cole790 Word 1 12-08-2013 03:55 PM
Merging pst files and moving to NAS drive riteoh Outlook 0 10-02-2012 05:20 AM
Moving body text from old files to new files (based on template) Moving files from one template to another Stephen0352 Word 4 03-05-2012 01:29 AM
moving data files g48dd Outlook 2 06-17-2011 01:18 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:54 AM.


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