Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2007

Tip: Looking for answers? Try searching our database.

Searching for section breaks that have got landscape orientation

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
andreas - 06 Aug 2007 16:36 GMT
Dear Experts:

Is it possible to search for only those section breaks that have got
LANDSCAPE orientation, using VBA?

Help is appreciated. Thank you very much in advance.

Regards, Andreas
Jonathan West - 06 Aug 2007 16:46 GMT
> Dear Experts:
>
[quoted text clipped - 4 lines]
>
> Regards, Andreas

Dim oSection as Section
For Each oSection in ActiveDocument.Sections
 If oSection.PageSetup.Orientation = wdOrientationLandscape Then
   'it is a landscape section
 Else
   'it isn't
 End If
Next oSection

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup

andreas - 06 Aug 2007 20:30 GMT
> > Dear Experts:
>
[quoted text clipped - 18 lines]
> Jonathan West - Word MVPwww.intelligentdocuments.co.uk
> Please reply to the newsgroup

Jonathan,

thank you, it is working
Regards,  Andreas
Helmut Weber - 06 Aug 2007 17:07 GMT
Hi Andreas,

>Is it possible to search for only those section breaks that have got
>LANDSCAPE orientation, using VBA?

hmm..., I think you want to find out
what section breaks cause landscape orientation
in the following section!

The section break, which causes this,
may be in an portrait section however.

You could expand Jonathan's solution
to locate the section break preceeding
the landscape section.

Or you could try this one:

Sub Test555()
Dim rDcm As Range
Set rDcm = ActiveDocument.Range
With rDcm.Find
  .Text = Chr(12)
  While .Execute
     MsgBox rDcm.Characters.Last.Next.PageSetup.Orientation
     ' 1 = landscape
  Wend
End With
End Sub

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

andreas - 06 Aug 2007 20:34 GMT
> Hi Andreas,
>
[quoted text clipped - 33 lines]
> Win XP, Office 2003
> "red.sys" & Chr$(64) & "t-online.de"

Helmut,

it is half working: the section break that features the landscape
orientation is found, but the macro  loops 12 times in a document with
three sections.

Regards, Andreas
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.