PDA

View Full Version : Print preview macro problem



musicgold
11-21-2010, 08:37 AM
Hi,

I have made a macro that allows me to Print Preview a Word page. I have assigned a key combination to the macro and am able to switch between the regular view and print preview. However, I am struggling with the following two issues. Please see my code below.


1. Focus page changes. When I get back to the normal view, the focus goes back to the page where I started the print preview mode. So in a 10 page document, if I start print preview at page 1 and scroll down to page 5 and then notice some error and switch back to the regular mode to edit, Word takes me back to page 1. I want to be able to stay on page 5.

2. Print preview starts at the begining of the page. Print preview always shows the start of the page. For example, I am at the end of a page and switch to the print preview mode, Word displays the beginning of the page, so I have to scroll to the end of the page. I want it to show me the spot on the page where I started print preview.

Can this be done ?



If (Application.PrintPreview = True) Then
Application.PrintPreview = fales
Exit Sub
End If

With ActiveWindow.View
.Type = wdPrintPreview
.Zoom.Percentage = 120
End With

Thanks,

MG.

Cross listed at http://www.mrexcel.com/forum/showthread.php?t=510302

fumei
11-22-2010, 10:05 AM
I would be interested if someone finds a solution to this. I am not sure if it is possible.

macropod
11-22-2010, 08:13 PM
Focus page changes. When I get back to the normal view, the focus goes back to the page where I started the print preview mode.That's how Print Preview works even when you're not driving it from vba. For what you're trying to do, you might be better off using Page Layout view (with formatting codes hidden) at a suitable zoom factor.

musicgold
11-22-2010, 08:44 PM
Thanks macropod.


Page Layout view (with formatting codes hidden)

I understand the Page layout view, but don't know what you mean by 'formatting codes hidden'.

macropod
11-22-2010, 08:51 PM
hi MG,

You toggle these on/off by clciking on the '¶' on the toolbar.

musicgold
11-22-2010, 09:09 PM
Oh ! I get. Thanks a lot macropod. I appreciate it.