I have this code in VBA for Word 2010:
Public LastBodyPage
Sub tryit()
Selection.GoTo What:=wdGoToBookmark, Name:="AppendixStart"
LastBodyPage = Selection.Information(wdActiveEndPageNumber)
End Sub
Sub vardel()
MsgBox Variables.item("LastBodyPage").Value
MsgBox LastBodyPage
End Sub
When the vardel procedure is run, the first message box displays "53" and the second time it displays "50".
Why am I getting different values??
You're looking at two different things:
The first message box displays something called
Variables.item(your code does not compile, what isVariables.item?).Anyway, the second message box displays something completely different, it displays
LastBodyPagewhich you presumably set usingtryit.