Solved

MS Word and pagenumbers

Posted on 2003-11-25
18
377 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
Comment Utility
Problem solved by using Macro Recorder........please cancel and refund.
0
 
LVL 96

Expert Comment

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

Author Comment

by:scorpion53061
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
I can't quite tell, but is there a space after Martens in TypeText?
0
 

Author Comment

by:scorpion53061
Comment Utility
no
0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
Nothing is leaping off the page on this one.
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:scorpion53061
Comment Utility
:(
0
 

Author Comment

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

Expert Comment

by:Bob Learned
Comment Utility
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
Comment Utility
I figured it out.........did you figure it out already?

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

Expert Comment

by:Bob Learned
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
PAQed, with points refunded (500)

SpazMODic
EE Moderator
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
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:…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 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

7 Experts available now in Live!

Get 1:1 Help Now