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
LVL 3
mte01Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

omegaomegaDeveloperCommented:
Hello, mte01,

Yes.  For the three items that you mention you could do something like:

        Dim docNew As New Word.Document
        docNew.Sections.Item(1).Footers.Item(1).Range.Text = "Here is some footer text"
        docNew.Sections.Item(1).Footers.Item(1).PageNumbers.Add(PageNumberAlignment:=0)
        docNew.Range.Text = "Here is some text, in which the font of the third word will be changed."
        docNew.Words.Item(3).Font.Name = "Courier New"
        docNew.Words.Item(3).Font.Size = 16

Cheers,
Randy

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mte01Author Commented:
hi, thanks for the help it's working but i just to need to set the location of these things, i need them to be something like that:

          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
omegaomegaDeveloperCommented:
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).Footers.Item(1).Range

        rngFooter.Fields.Add(Range:=rngFooter, Type:=wdFieldNumPages)
        rngFooter.Collapse()
        rngFooter.Text = " of "
        rngFooter.Collapse()
        rngFooter.Fields.Add(Range:=rngFooter, 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
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

mte01Author Commented:
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
omegaomegaDeveloperCommented:
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
mte01Author Commented:
>>omegaomega

Can you please provide help in this: http:Q_21837643.html
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Fonts Typography

From novice to tech pro — start learning today.