Insert a blank paragraph and page number in footer

A

Angie M.

Hi,

I'm trying to do something simple and have tried code snips from other
answers on this site but can't seem to make it work without errors.

Our footers already contain a document name in 8pt font. I need to create a
macro that will go into the footer, create a new paragraph at the beginning
of the footer and center a page number in Times New Roman 12 pt font. So you
end up with the page number centered on the first line and then the document
name on the 2nd line, left aligned with an 8pt font. If the document has a
different first page footer I do not want thte page number on the first page,
only the primary footer. Using the existing "page number" style for
formatting will work fine.

Here's what I have at this point after trying lots of things:

Dim myrange As Range
Set myrange = ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary)
myrange.InsertParagraphBefore

I've also tried working with the collapse method and pressing Enter for the
blank line with no luck.

Thanks for any help.
 
A

Angie M.

Sorry forgot to add that I do have the page numbering piece which is:

Selection.Sections(1).Footers(1).PageNumbers.Add PageNumberAlignment:= _
wdAlignPageNumberCenter, firstPage:=False
 
D

Doug Robbins - Word MVP

Use:

Dim frange As Range
Set frange = ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range
frange.InsertBefore vbCr
frange.Collapse wdCollapseStart
ActiveDocument.Fields.Add frange, wdFieldEmpty, "Page"
With frange.Paragraphs(1)
.Alignment = wdAlignParagraphCenter
With .Range.Font
.Name = "Times New Roman"
.Size = 12
End With
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

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