Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-27-2012, 06:45 AM
jaywalker jaywalker is offline Changing multpile documents Windows XP Changing multpile documents Office 2010 32bit
Novice
Changing multpile documents
 
Join Date: Feb 2012
Posts: 1
jaywalker is on a distinguished road
Default Changing multpile documents

Hi,


I have to add a footer with an updating date field on every document in our drive. I can do this manually but is very slow going. Is there an easier way to do this?
Any help would be appreicated
Jay
Reply With Quote
  #2  
Old 02-27-2012, 03:55 PM
macropod's Avatar
macropod macropod is offline Changing multpile documents Windows 7 64bit Changing multpile documents Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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 Jay,

Here's a macro to try. Simply run the UpdateDocuments procedure, select the folder to process and let the code run. You may need to change the '"DDDD, D MMMM YYYY" string to get the date format you want, so try it on a folder containing just one document first. Note also that the code won't add the date field to a footer that already has one.
Code:
Sub UpdateDocuments()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, wdDoc As Document, oFld As Field, bFnd As Boolean
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.doc", vbNormal)
While strFile <> ""
  Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
  With wdDoc.Sections(1).Footers(wdHeaderFooterPrimary).Range
    bFnd = False
    For Each oFld In Fields
      If oFld.Type = wdFieldDate Then
        bFnd = True
        Exit For
      End If
    Next
    If bFnd = False Then
      .Fields.Add Range:=.Characters.Last, Type:=wdFieldDate, _
        Text:="\@ " & Chr(34) & "DDDD, D MMMM YYYY" & Chr(34), _
        PreserveFormatting:=False
    End If
  End With
  wdDoc.Close SaveChanges:=True
  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
If you don't know how to install/use a macro see: http://www.gmayor.com/installing_macro.htm
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing multpile documents Open documents changing font on subsequent templates mikmak Word 7 03-04-2012 08:23 PM
Changing multpile documents total slack not changing when changing duration ketanco Project 1 02-11-2012 07:23 AM
changing gsrikanth Excel Programming 8 02-08-2012 09:09 PM
Changing multpile documents Changing the From field jerem Outlook 2 10-29-2010 03:04 PM
changing font size without changing leading carolns Word 1 09-14-2009 12:30 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:21 AM.


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