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

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
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,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

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