Solved

MS Word and pagenumbers

Posted on 2003-11-25
18
379 Views
Last Modified: 2012-06-21
Hi,

I need to insert a page number left centered into the header that appears such as this:

Martens 1

and on page two it would appear as

Martens 2

and I am going mad trying to find a result.

Thank you all for your help!!
0
Comment
Question by:scorpion53061
  • 8
  • 8
18 Comments
 

Author Comment

by:scorpion53061
ID: 9817234
Problem solved by using Macro Recorder........please cancel and refund.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9817730
Please post a comment in Community Support to have this question deleted and points refunded.
0
 

Author Comment

by:scorpion53061
ID: 9817854
Learned One!!

I was wrong.....

This did everything I wanted it to do except it left 2 spaces between the page number and "Martens" i.e. "Martens  1" instead of "Martens 1"

What did I do wrong??

If oDoc.ActiveWindow.View.SplitSpecial <> CInt(Word.WdSpecialPane.wdPaneNone) Then
                oDoc.ActiveWindow.Panes(2).Close()
            End If
            If oDoc.Content.Application.ActiveWindow.ActivePane.View.Type = CInt(Word.WdViewType.wdNormalView Or oDoc.ActiveWindow. _
                            ActivePane.View.Type = CInt(Word.WdViewType.wdOutlineView)) Then
                oDoc.ActiveWindow.ActivePane.View.Type = CInt(Word.WdViewType.wdPrintView)
            End If
            oDoc.Content.Application.ActiveWindow.ActivePane.View.SeekView = CInt(Word.WdSeekView.wdSeekCurrentPageHeader)
            oDoc.Content.Application.Selection.ParagraphFormat.Alignment = CInt(Word.WdParagraphAlignment.wdAlignParagraphLeft)
            With oDoc.Content.Application.Selection.HeaderFooter.PageNumbers
                .NumberStyle = CInt(Word.WdPageNumberStyle.wdPageNumberStyleArabic)
                .HeadingLevelForChapter = 0
                .IncludeChapterNumber = False
                .ChapterPageSeparator = CInt(Word.WdSeparatorType.wdSeparatorHyphen)
                .RestartNumberingAtSection = False
                .StartingNumber = 0
            End With
            oDoc.Content.Application.Selection.HeaderFooter.PageNumbers.Add(PageNumberAlignment:= _
                    CInt(Word.WdParagraphAlignment.wdAlignParagraphRight), FirstPage:=True)
            oDoc.Content.Application.Selection.ParagraphFormat.Alignment = CInt(Word.WdParagraphAlignment.wdAlignParagraphRight)
            oDoc.Content.Application.Selection.TypeText(Text:="Martens")
            oDoc.Content.Application.ActiveWindow.ActivePane.View.SeekView = CInt(Word.WdSeekView.wdSeekMainDocument)
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9817876
On the line where the page numbers are, what are the tabs like?  Is this spacing because of spaces or tabs?
0
 

Author Comment

by:scorpion53061
ID: 9818459
it is where when I insertd the page number that it put it and I aligned it right..........it automatically put hte page number there.


oDoc.Content.Application.Selection.HeaderFooter.PageNumbers.Add(PageNumberAlignment:= _
                    CInt(Word.WdParagraphAlignment.wdAlignParagraphRight), FirstPage:=True)
            oDoc.Content.Application.Selection.ParagraphFormat.Alignment = CInt(Word.WdParagraphAlignment.wdAlignParagraphRight)
            oDoc.Content.Application.Selection.TypeText(Text:="Martens")
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9818474
I can't quite tell, but is there a space after Martens in TypeText?
0
 

Author Comment

by:scorpion53061
ID: 9818496
no
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9818766
Nothing is leaping off the page on this one.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:scorpion53061
ID: 9818868
:(
0
 

Author Comment

by:scorpion53061
ID: 9818874
if you are stumped I will never find it :)
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9818875
I will try this with my Word XP after lunch in about an hour.  If I forget about this one, just give me a gentle nudge.
0
 

Author Comment

by:scorpion53061
ID: 9819031
I figured it out.........did you figure it out already?

(If I beat the master....... :) )
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9819287
Just got back from lunch, to see an E-Mail in my box.  I hadn't gotten to it, and now I don't think that it is important to.  I wouldn't call myself the "master", per se, but I do have enough expertise to call myself an expert.  More of these kinds of questions, and a few more years with automation, and I would say that that moniker would stick!

So, what did you find, grasshopper?
0
 

Author Comment

by:scorpion53061
ID: 9819832
LOL.........

Ok but now you have to give me your email so I can pick your brain ok? (admin@jjkoepsell.com)

The answer is (was)....

.Sub PageFormat()
        Dim oDoc As Word.Document
        <edited by request from the poster scorpion53081>
        End If
        oDoc.Content.Application.ActiveWindow.ActivePane.View.SeekView = CInt(Word.WdSeekView.wdSeekCurrentPageHeader)
        'oDoc.Content.Application.ActiveWindow.ActivePane.View.SeekView = CInt(Word.WdSeekView.wdSeekEvenPagesHeader)
        oDoc.Content.Application.Selection.ParagraphFormat.Alignment = CInt(Word.WdParagraphAlignment.wdAlignParagraphRight)
        oDoc.Content.Application.Selection.TypeText(Text:="Martens ")
        oDoc.Content.Application.Selection.Fields.Add(Range:=oDoc.Content.Application.Selection.Range, Type:=CInt(Word.WdFieldType.wdFieldEmpty), Text:="page")
        oDoc.Content.Application.ActiveWindow.ActivePane.View.SeekView = CInt(Word.WdSeekView.wdSeekMainDocument)
    End Sub

0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9819848
Aaah, the old adding a field instead of adding a page number trick.  Very good grasshopper!

BTW, in this day and age of spams, no E-Mails, thank you.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9819862
You can refer back to my original post, and ask Community Support to PAQ/Refund this question, since you found the solution, and there is valuable information for those searchers out there.
0
 

Accepted Solution

by:
SpazMODic earned 0 total points
ID: 9840047
PAQed, with points refunded (500)

SpazMODic
EE Moderator
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now