Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2004

Tip: Looking for answers? Try searching our database.

odd page numbers

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Drake - 04 Nov 2004 01:15 GMT
Hi - I am wanting to add a piece of code that will add a page break at the
end of the document if the last page is an odd numbered page.  Therefore,
this would create an even-numbered pages document.

So far,
dim pagenumber as Integer
Set pagenumber = Selection.Information(wdActiveEndPageNumber)
           if pagenumber = cint(3,5,7,9)

What am I doing wrong?
DA - 04 Nov 2004 06:05 GMT
Hi Drake

Try this:

Selection.EndKey Unit:=wdStory
If ActiveDocument.Range.Information
(wdActiveEndPageNumber) _
  Mod 2 <> 0 Then _
  Selection.InsertBreak Type:=wdPageBreak

Hope this helps,
Dennis
>-----Original Message-----
>Hi - I am wanting to add a piece of code that will add a page break at the
[quoted text clipped - 9 lines]
>
>.
Jay Freedman - 04 Nov 2004 20:29 GMT
For something completely different -- a non-macro solution -- see
http://word.mvps.org/faqs/tblsfldsfms/InsEvnPgEndChap.htm.

Signature

Regards,
Jay Freedman
Microsoft Word MVP          FAQ: http://word.mvps.org

> Hi Drake
>
[quoted text clipped - 21 lines]
>>
>> .
Drake - 04 Nov 2004 23:53 GMT
Thanks Jay - I had looked at that but wasn't sure how to do it and thought
VBA would be cleaner as I already have a script going.

Thanks Dennis - working good.  However, it seems that this If....Then is
functioning different than other ones I have done as it isn't accepting an
End If.  Also, I want to have it do a few other things, but it isn't working
correctly.  Here is what I added:

Selection.EndKey Unit:=wdStory
        Selection.Paste
    pagenumber = Selection.Information(wdActiveEndPageNumber)
           If pagenumber Mod 2 <> 0 Then _
           Selection.InsertBreak Type:=wdPageBreak
           Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
           Selection.Font.ColorIndex = wdGray25
           Selection.TypeText Text:="This Page Intentionally Blank"

It does everything fine if the last page is odd, but if it is even, I end up
with "This Page Intentionally...." which I don't want.

What am I missing?

> For something completely different -- a non-macro solution -- see
> http://word.mvps.org/faqs/tblsfldsfms/InsEvnPgEndChap.htm.
[quoted text clipped - 24 lines]
> >>
> >> .
Drake - 05 Nov 2004 00:05 GMT
My mistake - I think I was leaving a "_" in and mixing single and block If
syntax.

Working great!

> Thanks Jay - I had looked at that but wasn't sure how to do it and thought
> VBA would be cleaner as I already have a script going.
[quoted text clipped - 46 lines]
> > >>
> > >> .

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.