PDA

View Full Version : How insert break for selection of text?



akokin
09-04-2007, 11:52 PM
Hi. I want to insert break page for selection of text and set for it orientation (wdOrientLandscape). Only for selection. I do in such a way:


Dim myRange As Range
Set myRange = ActiveDocument.Range(Start:=Selection.Start, End:=Selection.End)

With myRange
.Collapse direction:=wdCollapseStart
.InsertBreak Type:=wdSectionBreakNextPage
.PageSetup.Orientation = wdOrientLandscape
End With
This code is inserting break before selection and do set orientation of landscape. But I want it to only for myRange but not for all pages. How I should do next?
Thanks.

SOS
09-05-2007, 12:30 AM
If the line


Set myRange = ActiveDocument.Range(Start:=Selection.Start, End:=Selection.End)


actually selects some text it will work, but if the cursor is at the beginning of your range and you don't select it then the start point and the end point of your range are both the same and the break is inserted at the beginning of your range as you originally stated.

akokin
09-05-2007, 01:35 AM
Thank you.
Now I did in such way:

Dim myRange As Range
Set myRange = ActiveDocument.Range(Start:=Selection.End, End:=Selection.End)
myRange.InsertBreak Type:=wdSectionBreakNextPage
Set myRange = ActiveDocument.Range(Start:=Selection.Start, End:=Selection.Start)
myRange.InsertBreak Type:=wdSectionBreakNextPage
myRange.PageSetup.Orientation = wdOrientLandscape That I wanted.

And I think that need to insert into this code next operator: "myRange = Nothing". Are you?

fumei
09-05-2007, 02:55 PM
If THIS is the issue:
But I want it to only for myRange but not for all pages. the answer is very simple.

It has to be in its own Section.