A Microsoft Word forum. Microsoft Office Word Forum - WordBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Microsoft Office Word Forum - WordBanter forum » Microsoft Word Newsgroups » Microsoft Word Help
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

change font header and footer



 
 
Thread Tools Display Modes
  #1  
Old April 25th 08, 10:03 AM posted to microsoft.public.word.docmanagement
Brie
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.
Ads
  #2  
Old April 25th 08, 10:33 AM posted to microsoft.public.word.docmanagement
Graham Mayor
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  
Old April 25th 08, 11:08 AM posted to microsoft.public.word.docmanagement
Brie
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  
Old April 25th 08, 11:38 AM posted to microsoft.public.word.docmanagement
Graham Mayor
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.



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
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 4 December 21st 06 07:54 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 02:32 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright 2004-2021 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.