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 / January 2005

Tip: Looking for answers? Try searching our database.

Calculating in VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Roderick O'Regan - 28 Jan 2005 18:25 GMT
This expression tells me which page I'm on:
Selection.Information(wdActiveEndPageNumber)

I want to do something if a page is odd or something different if it
is an even number.

Is there a way of doing this in VBA, please?

I was looking for something that would allow me to divide a page
number by 2. If the remainder was not zero then it must be an odd
number. That's my logic but I cannot work that in VBA.

Regards

Roderick O'Regan
Greg - 28 Jan 2005 19:07 GMT
Roderick,

Sub PageCheck()
If Selection.Information(wdActiveEndPageNumber) Mod 2 = 0 Then
MsgBox "Even page"
'do something
Else
 MsgBox "Odd page"
 'do something else
End If
End Sub
Roderick O'Regan - 29 Jan 2005 13:45 GMT
Greg,

Thank you for the advice. It worked wonderfully!

Regards

Roderick

>Roderick,
>
[quoted text clipped - 7 lines]
>End If
>End Sub
Helmut Weber - 28 Jan 2005 22:35 GMT
Hi Roderick,

it is the somewhat quirk "mod" operator, you need.
I prefer my own boolean function "isEven".
Shouldn't be a problem to set it up, once you got the principle.

Sub Test4444()
Dim l As Long
l = Selection.Information(wdActiveEndPageNumber)
If l Mod 2 = 0 Then
  MsgBox "even"
Else
  MsgBox "odd"
End If
End Sub

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
Roderick O'Regan - 29 Jan 2005 13:49 GMT
Thanks to you also Helmut.

I don't know what we would do without you guys!

Roderick

>Hi Roderick,
>
[quoted text clipped - 18 lines]
>Word XP, Win 98
>http://word.mvps.org/
 
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.