Word Macro Adjusts Page Orientation

devanrose33

New Member
Joined
Dec 8, 2015
Messages
6
Hi,

I'm writing a macro in Microsoft Word 2010. The macro itself is inserting and deleting bookmarks based on user inputs in an excel document.

There is one table in this document that is 6 pages long and I adjusted the orientation to Landscape for these pages only. The rest of this document is portrait.

When I run my macro, everything runs correctly but it changes these few pages orientation back to portrait. Is there any kind of code I can insert in the code to prevent the page setup from changing?

Or, if not, a way to tell the word VBA to adjust the orientation from page # - #

Thanks!
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Word shouldn't arbitrarily be changing your page orientation. I'm going to assume that when it's deleting a bookmark, it's also deleting a section break that's being used to change the page orientation.
 
Upvote 0
Starl,

Yes, you are correct! Thank you!

The issue is that one of the section breaks for this orientation change had an extra paragraph right before it. I have a piece of code at the end to delete all extra paragraphs and this was getting deleted. Deleting the paragraph before the section break eliminated this issue.
 
Upvote 0

Forum statistics

Threads
1,215,511
Messages
6,125,250
Members
449,218
Latest member
daynle

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top