Word 2013 Macro Not Working As Predicted

Sometimes I receive Word documents that have a layout other than the one I prefer. When such a document is open on my screen, I can put it into the format I prefer by clicking on the "One Page" button and then click on the "100%" button. When I record a macro following those same two steps, the result is not the same. The macro below causes the layout to go to a single page, but the Zoom is not 100%. What am I doing wrong? Is Word recording an incorrect command?

Sub OnePage100()
'
' OnePage100 Macro
'
    ActiveWindow.ActivePane.View.Zoom.PageFit = wdPageFitFullPage
    ActiveWindow.ActivePane.View.Zoom.Percentage = 100

End Sub

There is nothing wrong with the commands and they work for me on Word 2013 (64bit version).

However, I have read that for some people with Office 2013 the zoom percent does not work.

Make sure your Office version is fully updated and if that still does not help then try this command instead.

    ActiveWindow.ActivePane.Zooms(wdPrintView).Percentage = 100

________________________________
Richard V. Michaels
info@greatcirclelearning.com
Provides AuthorTec add-ins for Mac & Win-Office. Site: greatcirclelearning.com

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

There is nothing wrong with the commands and they work for me on Word 2013 (64bit version).

However, I have read that for some people with Office 2013 the zoom percent does not work.

Make sure your Office version is fully updated and if that still does not help then try this command instead.

    ActiveWindow.ActivePane.Zooms(wdPrintView).Percentage = 100

I'm using the latest 64-bit version as well. Let me be sure that I correctly described the problem. When I open some documents, they open in the "Multiple Pages" view. When I click on "One Page", the document switches to the single page view. When I click on "100%", the page zooms to 100%. Everything works correctly there.

When I record a macro following the same sequence, the macro does not perform the same way. When I run the macro, Word keeps the Multiple Pages view but does zoom to 100%. Here is the code (including the change suggested above):

Sub OnePage100()
'
' OnePage100 Macro
'
'
    ActiveWindow.ActivePane.View.Zoom.PageFit = wdPageFitFullPage
    ActiveWindow.ActivePane.Zooms(wdPrintView).Percentage = 100
End Sub

I tried to see if inserting a pause would make a difference, but I couldn't find a way to insert one. Any help to solve this problem would be appreciated.

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Try putting a DoEvents command between the two statements in the routine.
________________________________
Richard V. Michaels
info@greatcirclelearning.com
Provides AuthorTec add-ins for Mac & Win-Office. Site: greatcirclelearning.com

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Try putting a DoEvents command between the two statements in the routine.

Unfortunately, no joy. The way I test is to open a multi-page document in the Print Layout mode, click on Multiple Pages, and then run the macro. While the 100% zoom works, two pages are still displayed on the screen. If I click on One Page and then 100%, the document is displayed correctly. That is, when this line is executed,

"ActiveWindow.ActivePane.Zooms(wdPrintView).Percentage = 100"

the screen displays two side-by-side pages.

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

This oddity is related to the aspect ratio of your monitor, which is 16:9 ratio. Word displays 2 pages at 100% on a 16:9 monitor, but only one on a 4:3 monitor. It sounds like as soon as the second command fires, Word forgets about the first and uses its internal preferences.

When you record each statement in the Macro recorder, they are fired in sequence. Rewriting as below should fire them simultaneously. When I test here, both of these work:

With ActiveWindow.ActivePane

    .View.Zoom.PageFit = wdPageFitFullPage
    .Zooms(wdPrintView).Percentage = 100

End With

OR

With ActiveWindow.ActivePane.View.Zoom
  .PageFit = wdPageFitFullPage
  .Percentage = 100
End With

Author of "OOXML Hacking - Unlocking Microsoft Office's Secrets", ebook now out
John Korchok, Production Manager
production@brandwares.com

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated October 5, 2021 Views 192 Applies to: