mte01
asked on
word report add page number and change text font
hi guys,
im generating a word report, what i need is to put the page number and a small text on each page footer, can this be done. like the text on the left and the page number on the left.
and i need to change the font of a specific section or text in the report, is that dooable?
thanks
im generating a word report, what i need is to put the page number and a small text on each page footer, can this be done. like the text on the left and the page number on the left.
and i need to change the font of a specific section or text in the report, is that dooable?
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hello, mte01,
There are many possible ways to do this. Typically the footer defaults to having a center-tab in the middle and a right-tab on the right. If this is the case for your report, then you could do this:
Const wdFieldNumPages As Integer = 26
Const wdFieldPage As Integer = 33
Dim docNew As New Word.Document
Dim rngFooter As Word.Range
rngFooter = docNew.Sections.Item(1).Fo oters.Item (1).Range
rngFooter.Fields.Add(Range :=rngFoote r, Type:=wdFieldNumPages)
rngFooter.Collapse()
rngFooter.Text = " of "
rngFooter.Collapse()
rngFooter.Fields.Add(Range :=rngFoote r, Type:=wdFieldPage)
rngFooter.Collapse()
rngFooter.Text = "Here is some Text" & vbTab & vbTab & "Page "
If the tabstops in the footer are different than normal you would need to modify them before using the above (or modify the above as necessary).
Cheers,
Randy
There are many possible ways to do this. Typically the footer defaults to having a center-tab in the middle and a right-tab on the right. If this is the case for your report, then you could do this:
Const wdFieldNumPages As Integer = 26
Const wdFieldPage As Integer = 33
Dim docNew As New Word.Document
Dim rngFooter As Word.Range
rngFooter = docNew.Sections.Item(1).Fo
rngFooter.Fields.Add(Range
rngFooter.Collapse()
rngFooter.Text = " of "
rngFooter.Collapse()
rngFooter.Fields.Add(Range
rngFooter.Collapse()
rngFooter.Text = "Here is some Text" & vbTab & vbTab & "Page "
If the tabstops in the footer are different than normal you would need to modify them before using the above (or modify the above as necessary).
Cheers,
Randy
ASKER
thanks for the help, it's working now,
do u have a tutorial on how to build word document and things like that? coz i cant find any
do u have a tutorial on how to build word document and things like that? coz i cant find any
Hello, mte01,
No, I'm sorry I don't have a good reference for this. I don't normally do a lot of work with Word.
A general technique that I have often found helpful is to record a Word macro while I manually perform the steps required. The VBA in the macro produced is typically not directly useful, but can give some good clues about the properties and methods that can be used.
Cheers,
Randy
No, I'm sorry I don't have a good reference for this. I don't normally do a lot of work with Word.
A general technique that I have often found helpful is to record a Word macro while I manually perform the steps required. The VBA in the macro produced is typically not directly useful, but can give some good clues about the properties and methods that can be used.
Cheers,
Randy
ASKER
ASKER
bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
Here is some footer text page 1 of 1
what i meant is to have the text on the left and the page number on the right section of the document.
thanks again for the help