Exit "Here" From Print Preview

J

Joan NYC

One thing I really miss like crazy from my last job was what we called an
"Exit Here" Macro

If you were in Print Preview viewing page x and you closed Print Preview you
wound up on page x

This was extremely helpful when working on very long docs

If anyone wants to share with me I would really appreciate it

Thanks
 
J

Jezebel

Dim pPageNumber As Long

pPageNumber =
ActiveDocument.ActiveWindow.ActivePane.Selection.Information(wdActiveEndPageNumber)
ActiveDocument.ClosePrintPreview
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:=pPageNumber
 
R

Russ

That line and code all the way to the closing parenthesis must be on the
same line in the editor.
 
J

Joan NYC

Thanks

I will try it

Jezebel said:
Dim pPageNumber As Long

pPageNumber =
ActiveDocument.ActiveWindow.ActivePane.Selection.Information(wdActiveEndPageNumber)
ActiveDocument.ClosePrintPreview
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:=pPageNumber
 
R

Russ

Code often gets line wrapped in the Newsgroup forums, thereby causing a
mistake if taken literally in the VBA editor.

Two ways to make learning easier are to hit the F1 function key when the
cursor is in a word in the VBA Editor to bring up contextual VBA Help; and
to single-step Run through the code using the F8 function key and pausing
every once in a while during single-step Run mode to hover the cursor over
different words in the code to see if any tooltip info pops up.

You can also use Debug windows to watch variables as they change, etc.

As you may have noticed when you manually type in code, the VBA Editor will
prompt you with choices to make things faster each time you type the full
stop or period between words.
 
J

Joan NYC

Yes, I did notice how the VBA editor works

However, it is like learning a language which is why I have been unsuccessful

As a former Word MVP one of the perks was free software and I have a copy of
Visual Basic here as well as several books. I get to a certain point and get
stuck!
 

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