Solved

MS Word and pagenumbers

Posted on 2003-11-25
18
383 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

 
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

717 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