View Single Post
  #7   Report Post  
Posted to microsoft.public.word.tables,microsoft.public.word.vba.general
Jean-Guy Marcil
 
Posts: n/a
Default How many lines used in a table cell?

Jezebel was telling us:
Jezebel nous racontait que :

I've followed it far enough to establish that you can retrieve the
individual lines on the page; but quite how, I don'tknow.


Something like this:

'_______________________________________
Dim i As Long
Dim strTargetLine As String

With ActiveWindow.Panes(1).Pages(1)
If .Rectangles.Count 1 Then
For i = 1 To .Rectangles.Count
If .Rectangles(i).RectangleType = wdTextRectangle Then _
If .Rectangles(i).Range.StoryType = wdMainTextStory Then
Exit For
Next
End If
strTargetLine = .Rectangles(i).Lines(5).Range.Text
End With
'_______________________________________

You have to check for the rectangle type because as soon as you start adding
shape or textboxes, things don't add up...

Try the above with a header and some text, as expected you will get 2
rectangles.
Now add a text box... now you have 6 rectangles!

If you run this code:

'_______________________________________
With ActiveWindow.Panes(1).Pages(1)
If .Rectangles.Count 1 Then
For i = 1 To .Rectangles.Count
MsgBox .Rectangles(i).RectangleType _
& vbCrLf & .Rectangles(i).Range.StoryType
Next
End If
End With
'_______________________________________

It will error out on rectangle 5 and 6 because those do not have ranges:

Rectangle 1 = 0 7 (Text rectangle PrimaryHeader Story)
Rectangle 2 = 0 1 (Text rectangle Main Story)
Rectangle 3 = 1 1 (Shape rectangle Main Story)
Rectangle 4 = 0 5 (Text rectangle Textframe Story)
Rectangle 5 = 7 n/a (System rectangle) The helpful help says "Not
applicable" as a description of the System type...
Rectangle 6 = 6 n/a (Selection rectangle) This is the actual anchor for the
shape.


--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org