?
Solved

MS Word and pagenumbers

Posted on 2003-11-25
18
Medium Priority
?
396 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
17 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
Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

 
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
 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month16 days, 9 hours left to enroll

862 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