Searching for sections with landscape orientation and display them ina msgbox

A

andreas

Dear Experts:

I wonder whether it is possible to list all the sections with a
landscape page orientation in a msgbox, such as:

The following sections have landscape orientation:

Section 5 starting on page 7 (ActveEndAdjustedPageNumber)
Section 9 starting on page 15 (ActiveEndAdjustedPageNumber)
.... etc.

Or msgbox ("no sections with landscape orientation in this document")

Help is much appreciated. Thank you very much in advance.

Regards, Andreas
 
G

Greg Maxey

Something like this maybe:

Sub Test()
Dim pStr As String
Dim oSec As Section
Dim oRng As Word.Range
For Each oSec In ActiveDocument.Sections
If oSec.PageSetup.Orientation = wdOrientLandscape Then
Set oRng = oSec.Range
oRng.Collapse wdCollapseStart
pStr = pStr & " Section " & oSec.Index & " starting on page " &
oRng.Information(wdActiveEndPageNumber)
End If
Next
MsgBox pStr
End Sub
 
A

andreas

Something like this maybe:

Sub Test()
Dim pStr As String
Dim oSec As Section
Dim oRng As Word.Range
For Each oSec In ActiveDocument.Sections
  If oSec.PageSetup.Orientation = wdOrientLandscape Then
    Set oRng = oSec.Range
    oRng.Collapse wdCollapseStart
    pStr = pStr & " Section " & oSec.Index & " starting on page " &
oRng.Information(wdActiveEndPageNumber)
  End If
Next
MsgBox pStr
End Sub












--
Greg Maxey -  Word MVP

My web sitehttp://gregmaxey.mvps.org
Word MVP web sitehttp://word.mvps.org- Hide quoted text -

- Show quoted text -


Hey Greg,

yes, it is working just fine. Exactly what I needed. Thank you very
much. Regards, Andreas
 

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