Macro to landscape a table

I

ion

I just found out that one of the abilities Word 2007 stripped me of
was that of putting a landscape formatted section in the middle of a
portrait document. I wrote a macro that will find the first table
following a selection and make it landscape. Enjoy!


Sub LandscapeFollowingTable()
Dim sec As Word.Section, rng As Word.Range
Set rng = Selection.Range
'find the next table -- I'd find the enclosing table if I could
Set rng = rng.Next(wdTable, 1)
'create a section break before the table
Set sec = ActiveDocument.Sections.Add(rng, wdSectionContinuous)
'create a section break after the table
ActiveDocument.Sections.Add rng.Next, wdSectionContinuous
sec.PageSetup.Orientation = wdOrientLandscape
End Sub
 
J

Jay Freedman

Word 2007 did _not_ remove that ability. As with everything else, it's
just in a different place -- and in this case, not all that different.

After selecting the table, or any other text you want in a landscape
section, click the dialog launcher (the tiny button at the right end
of the group title) of the Page Layout > Page Setup group. In the
dialog (which is pretty much just the old File > Page Setup dialog),
set the Apply To box to "Selected text" and click the Landscape
button, then OK.

The thing that's different is that there's a separate Orientation
button in the Page Setup group, but that button operates on whatever
is currently chosen in the Apply To box even though you can't see the
dialog. Since that box defaults to "Whole document", clicking the
button without first visiting the dialog will reorient the entire
document even though something is selected. So your macro is useful if
you want to avoid having to go to the dialog.
 
I

ion

Thanks, Jay. No one in my office intuited that dialog box, but it's
nice to know there's someone out there who knows this stuff.

I used to be nostalgic for manuals. Now I'm nostalgic for local help.
 

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