Thanks for the appreciation...but I think it is not warranted, as I did not do anything. Frankly, it sounds more like sarcasm, but what the heck.
This function only tells me after I am on a new page and not right before, which is what I want.
I will repeat: if you are on NEW page,
there is no next page. How could there be? That is why it only tells you when you are on a new page "not before". There IS NO before, because there IS NO next page. As far as Word is concerned the document ends there (and it does), so there is NO next page. Word can not read minds; it can not tell if you are going to put in more text that will need a next page.
Also, .Content.Information(wdActiveEndAdjustedPageNumber) returns the page number of the last page.
Say you have a 13 page document. Your sub SetCurrentPage will make mCurrentPage = 13...REGARDLESS of where the Selection is. And, as I stated previously, current page is (normally) defined as where the Selection is. So if the Selection is on page 4, your mCurrentPage will = 13. hardly the current page now is it?
Further, your logic is faulty in the function. Continuing with the 13 page document example.
if mCurrentPage is NOT = 13, then
mCurrentPage = 13
NewPage = True
Else
NewPage = False
end if
That would be fine...except you have a comment to run SetCurrentPage first - which will make mCurrentPage = 13.
Please relax, don't thank me for something I have not helped with, and kindly state what it is you are trying to do.
"New" page. "Next" page.
Are you talking about a new page INSERTED into a document, then yes, sure, there is a next page.
But if it a word processing function (i.e. making another page, a "new" page) then there is NO "next" page.
If what you want is some routine that WHEN there is a new page created, that is another story, but you have not asked for that.
You asked for:
All I want to know is, with VBA, can I detect the an 'end of a new page' before I go on to the next. Or Even better, Can I tell what current page my selection is on?
The first part...no you can not, because there is no "next" page, unless you are on a page that already has pages after it.
The second part. Yes you can.
I may also point out that your code completely ignores the location of the Selection, which - although you did not state what it is you are trying to do - may be something you are trying to work with.
Gerry