PDA

View Full Version : Format Footer Text



Sparkyrose
02-07-2008, 08:30 AM
Hi,

I'll begin by saying I'm not a programmer of VBA (or anything for that matter!) but I'm just trying to get one little thing to work.

I have obtained a macro from the maker of my company's document management system that will insert the DM ref no in the footer of all word docs. It works fine, except I wanted to format the text to 7 point (it defaults to 12.)

This is the code:

Private Function FooterAttributes() As Collection
If mcolFooterAttributes.count = 0 Then
' Populate collection with default profile info
With mcolFooterAttributes
.Add imProfileDatabase, "1"
.Add imProfileDocNum, "2"
.Add imProfileVersion, "3"
End With
End If
Set FooterAttributes = mcolFooterAttributes
End Function

I'm sure it's a simple thing, I just have no idea how to make it work.

I tried adding: With Selection.Font
.Size = 7
End With

But it formatted the main body, not the footer.

Any help would be greatly appreciated!!

fumei
02-07-2008, 02:04 PM
"it formatted the main body, not the footer."

This is because you used Selection (which is the cursor location) and the cursor was not in the footer. You CAN move the cursor into the footer and do what you did - although you would also have to select the footer. However.....

You can format the font of any footer directly, without ever having to use selection, or go into the footer.ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary) _
.Range.Font.Size = 7This would make the entire Primary footer for Section 1 a font size of 7 pts.

You do not state if you have multiple footers, DifferentFirstPage, DifferentOddEven etc., or multiple Sections. The above code changes JUST the primary footer for Section 1.

Changing other footers is not a big deal though. For example, if you wanted to change ALL footers to 7pts, then:Dim oSection As Section
Dim oHF As HeaderFooter
For Each oSection In ActiveDocument.Sections
For Each oHF In oSection.Footers
oHF.Range.Font.Size = 7
Next
NextDone. All footers are now 7 pts.