> To test it I did this.
>
[quoted text clipped - 28 lines]
> > End If
> > End With
Hi Larry,
all I can say is, that
Selection.Information(wdFirstCharacterLineNumber)
is nothing new at all and has been offerred as a solution
here in this group for many times by lots of people.
My code is a bit shorter than Greg's, but that's all.
Basically it is exactly the same.
I tested it in normal view and print view.
IMHO, it returns always -1 if the selection is in a textframe.
...Shapes.AddTextbox
...ShapeRange.TextFrame.TextRange.Select
WrapToWindow seems to have no effect on
information(wdFirstCharacterLineNumber)
Maybe somebody else knows better.
I seem to be at the and of my wisdom.
Why do you want to know at all, whether start
and end of the selection are in the same line?
Though I know, this is often required.
If information(wdFirstCharacterLineNumber)
turns out to be unreliable, then their are
workarounds. Which may have their bugs and
limitations as well.
Like this, which assumes, that the text in the line
at the start of the selection is different form the text
in the line at the end of the selection.
Dim rTmp As Range
Set rTmp = Selection.Range
Dim l1 As String
Dim l2 As String
With Selection
l1 = .Bookmarks("\line").Range.Text
Selection.Collapse direction:=wdCollapseEnd
l2 = .Bookmarks("\line").Range.Text
If l1 <> l2 Then
MsgBox "different line"
End If
End With
rTmp.Select
If that fails too, one could check the position
of selection.start vs. the position of selection.end
in terms of vertical distance form e.g. the top of the page.
HTH

Signature
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
Larry - 08 Jan 2006 03:21 GMT
Helmut, thanks for the extra work on this, I'll try that too. But I
found another way that seems stable and is not dependent on the
Information property which is just not dependable on my machine.
In my setup, RightEdge is the Selection.End plus 2. It's too
complicated to explain what I'm doing this for. I'll just show you how
I solved this particular problem within the larger macro.
If RightEdge >= ActiveDocument.Bookmarks("\Line").Range.End Then
n = RightEdge - ActiveDocument.Bookmarks("\Line").Range.End
' My new method that works. If RightEdge is more than two greater than
end of line,
' then I know that the selection extends to two lines, and I run code
just for
' that situation.
If Selection.Type = wdSelectionNormal And n > 2 Then
' Selection runs to more than one line.
> Hi Larry,
>
[quoted text clipped - 51 lines]
>
> HTH
Larry - 08 Jan 2006 04:21 GMT
Here's a simpler way of expressing the same idea:
If Selection.Type = wdSelectionNormal _
And Selection.End > ActiveDocument.Bookmarks("\Line").Range.End Then
MsgBox "more than one line"
End If
Larry
> Helmut, thanks for the extra work on this, I'll try that too. But I
> found another way that seems stable and is not dependent on the
[quoted text clipped - 69 lines]
> >
> > HTH
Larry - 08 Jan 2006 18:13 GMT
It can be even simpler:
If Selection.End > ActiveDocument.Bookmarks("\Line").Range.End Then _
MsgBox "more than one line"
> Here's a simpler way of expressing the same idea:
>
[quoted text clipped - 80 lines]
> > >
> > > HTH
Larry - 08 Jan 2006 19:27 GMT
I just realized why I (and maybe others) didn't think of this simple
solution earlier: Since the selection is on two lines, I think I
assumed that the line bookmark whose end number is being returned would
be the second line's bookmark, since the end of the bookmark range is
indeed on the second line. And if it were the second line's bookmark,
then this code wouldn't work. But as it turns out,
ActiveDocument.Bookmarks("\Line").Range.End is the bookmark of the line
on which the selection and the bookmark begin, not the line on which
they end. This made the solution possible, comparing the end of the
selection with the end of the line on which the selection starts. .
Larry
> It can be even simpler:
>
[quoted text clipped - 86 lines]
> > > >
> > > > HTH
Helmut Weber - 08 Jan 2006 22:23 GMT
Pretty clever!
:-)

Signature
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"