Use VBA to change font size and to italics

M

Marilyn

I would like to change the font size/type, italicize, and
bold text in the header and footer section of a Word doc
using VBA from Access 2000.
 
D

Doug Robbins - Word MVP

Hi Marilyn,

Assuming that you have already created a document object, say wdDoc, and the
header and footer are in the first (only) section in the document, then you
would use:

With wdDoc.Sections(1)
.Headers(wdHeaderFooterPrimary).Range.Font.Size = 14
.Headers(wdHeaderFooterPrimary).Range.Font.Italic = True
.Headers(wdHeaderFooterPrimary).Range.Font.Bold = True
.Footers(wdHeaderFooterPrimary).Range.Font.Size = 14
.Footers(wdHeaderFooterPrimary).Range.Font.Italic = True
.Footers(wdHeaderFooterPrimary).Range.Font.Bold = True
End With

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
M

Marilyn

Thank you for you help. It worked wonderfully. However,
in the header I would like to only change the titles or
labels fonts but not the fields that are in the header.
Is there someway that I can change the titles or labels in
the headers and not the fields?
 
D

Doug Robbins - Word MVP

Hi Marilyn,

You will have to change the font of the fields back to what it was using
code such as

Dim af As Field
For Each af In
ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Fields
af.Result.Font.Size = 10
Next af

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a consulting basis.

Hope this helps
Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top