FileName in Footer Set to 8 pt

J

jerem

I posted this question yesterday, saw it posted on this site yesterday and
today this question is nowhere to be found. So I'm posing the question once
again.

I scavenged some code from this website (see below), made a couple of
changes here and there, however, cannot figure out how to get the FileName to
come into the footer as Font size 8. Can anyone help? Thanks in advance.

Sub NumberPages2()
'

Dim oRng As Range
Dim oSection As Section
Dim oFooter As HeaderFooter
Call SameAsPrevious
For Each oSection In ActiveDocument.Sections
For Each oFooter In oSection.Footers
If oFooter.Exists Then
Set oRng = oFooter.Range
With oRng
.Fields.Add oRng, wdFieldPage, , False
.InsertBefore "-"
.InsertAfter "-"
.Collapse wdCollapseEnd
.ParagraphFormat.Alignment = _
wdAlignParagraphCenter
.Fields.Add oRng, wdFieldFileName
.InsertAfter Chr(13)
.Collapse wdCollapseEnd
.ParagraphFormat.Alignment = _
wdAlignParagraphLeft

End With
End If
Next oFooter
Next oSection
End Sub
 
D

Doug Robbins - Word MVP

Use:

Dim oRng As Range
Dim oSection As Section
Dim oFooter As HeaderFooter
Call SameAsPrevious
For Each oSection In ActiveDocument.Sections
For Each oFooter In oSection.Footers
If oFooter.Exists Then
Set oRng = oFooter.Range
With oRng
.Fields.Add oRng, wdFieldPage, , False
.InsertBefore "-"
.InsertAfter "-"
.Collapse wdCollapseEnd
.ParagraphFormat.Alignment = _
wdAlignParagraphCenter
.Fields.Add oRng, wdFieldFileName
.InsertAfter Chr(13)
.Collapse wdCollapseEnd
.ParagraphFormat.Alignment = _
wdAlignParagraphLeft
End With
oFooter.Range.Paragraphs(2).Range.Font.Size = 8
End If
Next oFooter
Next oSection


--
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
 
J

jerem

Thanks Doug, that did the trick. Can I impose on you for one more thing?
I'd like for the page number to be absent on the first page (different first
page) but appear on all succeeding pages. Thanks again for your help.
 
G

Graham Mayor

Yestarday you posted your query in the docmanagement forum, where it
remains, along with my reply, which is similar to that Doug has posted here
:(

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
D

Doug Robbins - Word MVP

Use:

Dim oRng As Range
Dim oSection As Section
Dim oFooter As HeaderFooter
'Call SameAsPrevious
For Each oSection In ActiveDocument.Sections
Set oFooter = oSection.Footers(wdHeaderFooterPrimary)
Set oRng = oFooter.Range
With oRng
.Fields.Add oRng, wdFieldPage, , False
.InsertBefore "-"
.InsertAfter "-"
.Collapse wdCollapseEnd
.ParagraphFormat.Alignment = _
wdAlignParagraphCenter
.Fields.Add oRng, wdFieldFileName
.InsertAfter Chr(13)
.Collapse wdCollapseEnd
.ParagraphFormat.Alignment = _
wdAlignParagraphLeft
End With
oFooter.Range.Paragraphs(2).Range.Font.Size = 8
oSection.PageSetup.DifferentFirstPageHeaderFooter = True
Next oSection


--
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
 
J

jerem

Hey Graham,

Didn't know there was a docmanagement forum - thought it went into the forum
that I always post in - my bad. As you have probably recognized, I scavenged
your code (the UpdateFields one as well). My last entry stated that I was
looking to invoke Different 1st page for every section, however, didn't
specify that I needed that filename on every page. What I wanted different
about each 1st page of each section was the exclusion of the page numbering
only. I was trying to tinker with the modified code from the last post with
no success and then also realized wouldn't it be nice to kill 3 birds with
one stone -- that is, (1) File name on every page, (2) No page numbering on
the first page of every section and (3) every second page of each section
starting as page #2. Now I can try to accomplish that, however, what will
take you 5 minutes may take me days of scouring this website. Are you game?
Hope so! Thanks for your help.
 
D

Doug Robbins - Word MVP

Unless you are trying to modify an existing multi-section document, you
should probably just set up a template for the document with the headers and
footers in it that you require and use that template for new documents for
which that footer information is required.

However, if you do need to modify and existing multipage document, use:

Dim i As Long
Dim frange As Range
With ActiveDocument
For i = 1 To .Sections.Count
With .Sections(i)
.PageSetup.DifferentFirstPageHeaderFooter = True
With .Footers(wdHeaderFooterFirstPage)
With .PageNumbers
.RestartNumberingAtSection = True
.StartingNumber = 1
End With
Set frange = .Range
ActiveDocument.Fields.Add frange, wdFieldFileName
frange.Paragraphs(1).Range.Font.Size = 8
End With
With .Footers(wdHeaderFooterPrimary)
Set frange = .Range
ActiveDocument.Fields.Add frange, wdFieldPage
frange.InsertBefore "-"
frange.InsertAfter "-" & vbCr
frange.Paragraphs(1).Alignment = wdAlignParagraphCenter
frange.Collapse wdCollapseEnd
ActiveDocument.Fields.Add frange, wdFieldFileName
With frange.Paragraphs(1)
.Range.Font.Size = 8
.Alignment = wdAlignParagraphLeft
End With
End With
End With
Next i
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
 
G

Graham Mayor

Doug keeps different hours from me (opposite hemispheres of the world) and
has already provided the code you require.
There are lots of Word forums - http://www.gmayor.com/MSNews.htm is the
simplest way to access them.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
J

jerem

Yes, that would work if it were only me using them. However, since there are
others who would benefit from this and since I do not have rights to alter
the global template where I work, loading up this macro will do the trick.
Also, using varying macros allow flexibility from one document to the next.
This macro works great. Thanks for your help.
 
D

Doug Robbins - Word MVP

Such a modification should NOT be made to the global (normal) template. A
new template should be created with those footers set up in it and used when
that information is required to appear in documents.

To see how to distribute such a template for use by others, see the article
"Distributing macros to other users†at:

http://www.word.mvps.org/FAQs/MacrosVBA/DistributeMacros.htm


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