Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Brie Brie is offline
external usenet poster
 
Posts: 8
Default change font header and footer

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.
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default change font header and footer

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.



  #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.




  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default change font header and footer

You are welcome

--

Graham Mayor - Word MVP

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



Brie wrote:
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.



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I change the actual header and footer margins? latwood Page Layout 5 April 6th 23 01:56 PM
Can't change first header/footer in section to first page header [email protected] Page Layout 3 November 24th 05 03:21 PM
Header/footer font color Stranger Microsoft Word Help 2 August 25th 05 04:06 AM
How do I change the footer & header to the same text in multiple . Harry Page Layout 1 March 16th 05 08:57 PM
How do I change tabs in the header/footer of only one section ? richie Page Layout 1 February 10th 05 04:15 PM


All times are GMT +1. The time now is 03:31 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"