View Single Post
 
Old 02-02-2018, 11:56 AM
ksor ksor is offline Windows 10 Office 2016
Advanced Beginner
 
Join Date: Feb 2018
Location: Århus V, Denmark
Posts: 78
ksor is on a distinguished road
Default PAGE and NUMPAGES fields in footer ??

I made this short method to setup a header/footer in a word document:

Code:
Public Sub headerFooter(f As Form, bD As Word.Document)
    With bD.Sections(1)
        .Headers(wdHeaderFooterPrimary).Range.Text = "Alle registrerede data vedr. PersonId: " & f.PersonID & " " & HentFMENavn(f.PersonID)
        .Footers(wdHeaderFooterPrimary).Range.Text = "Sammensat " & StrConv(Format(Date, "dddd"), vbProperCase) & " den " & Date & vbTab & vbTab & "Side "
        .Footers(wdHeaderFooterPrimary).Range.Fields.add Selection.Range, wdFieldEmpty, "PAGE  ", True
        .Footers(wdHeaderFooterPrimary).Range.Text = " af "
        .Footers(wdHeaderFooterPrimary).Range.Fields.add Selection.Range, wdFieldEmpty, "NUMPAGES  ", True
    End With
End Sub
BUT the actual digits for the fields PAGE and NUMPAGES is NOT writen in the footer - they are writen in the normal text area !

What do I need to change in the code ?

EDIT: Now I see I should have posted in WORD VBA - sorry !
Reply With Quote