Calculating in VBA

R

Roderick O'Regan

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
 
G

Greg

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
 
H

Helmut Weber

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/
 
R

Roderick O'Regan

Thanks to you also Helmut.

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

Roderick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top