View Single Post
  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Brie Brie is offline
external usenet poster
 
Posts: 8
Default change font header and footer

Thanks a lot Graham!

It works great!

Brie

"Graham Mayor" wrote:

Assuming the documents are not protected forms and are not password
protected then the following should work

Sub BatchChangeHeaderFooter()
On Error GoTo err_FolderContents
Dim oSection As Section
Dim oHeader As HeaderFooter
Dim oFooter As HeaderFooter
Dim DocList As String
Dim DocDir As String
Dim fDialog As FileDialog
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)

With fDialog
.Title = "Select Folder containing the documents to be edited and click
OK"
.AllowMultiSelect = False
.InitialView = msoFileDialogViewList
If .Show -1 Then
MsgBox "Cancelled By User"
Exit Sub
End If
PathToUse = fDialog.SelectedItems.Item(1)
If Right(PathToUse, 1) "\" Then PathToUse = PathToUse + "\"
End With

If Documents.Count 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
Application.ScreenUpdating = False
DocList = Dir$(DocDir & "*.doc")
Do While DocList ""
Documents.Open DocList
For Each oSection In ActiveDocument.Sections
For Each oHeader In oSection.Headers
If oHeader.Exists Then
oHeader.Range.Font.name = "Arial"
End If
Next oHeader
For Each oFooter In oSection.Footers
If oFooter.Exists Then
oFooter.Range.Font.name = "Arial"
End If
Next oFooter
Next oSection
ActiveDocument.Close SaveChanges:=wdSaveChanges
DocList = Dir$()
Loop
Application.ScreenUpdating = True
Exit Sub
err_FolderContents:
MsgBox Err.Description
Exit Sub
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org




Brie wrote:
hi!

I have around 200 files which header and footer need to be change
from times new roman to arial.

can anyone help me with this using macro?

thanks in advance.