Re: How many lines used in a table cell?
- From: "Ed" <ed_millis@xxxxxxxxxxxxxxxxx>
- Date: Mon, 6 Feb 2006 06:47:25 -0700
I replied above through the .Tables NG, and so didn't see your posts. I
discovered (uncovered?) a method that seems to work even in a single cell
spanning several pages. I posted it above, but am copying here as well.
Sub Foo_countMyLines()
' To count lines in a table cell,
' select all text, BUT NOT the cell marker
' If the cell marker is selected and
' included in the range, the code
' returns "0" lines
Const wdStatisticLines = 1
Dim rng As Range
Set rng = Selection.Range
MsgBox "Lines: " & rng.ComputeStatistics(wdStatisticLines)
End Sub
"Helmut Weber" <nbhymsjxdgcn@xxxxxxxxxxxxxx> wrote in message
news:aitbu1htf40207nncssai8r9r23sseeto2@xxxxxxxxxx
Hi Jezebel and all co-reader,
how about this one, which deals with
cells spanning several pages.
Though quite slow, I have to admit,
improvements welcome,
and nothing else but using range
instead of selection, in a way.
On the other hand, how often do cells span several pages?
Public Function LinesInCell3(oCll As Cell) As Long
Dim lLin As Long
Dim lCnt As Long
Dim oChr As Word.Range
lLin = 0
For Each oChr In oCll.Range.Characters
If oChr.Information(10) <> lLin Then
lCnt = lCnt + 1
lLin = oChr.Information(10)
End If
Next
LinesInCell3 = lCnt - 1
End Function
' -------------------------------
Sub test00987()
With ActiveDocument.Tables(1)
MsgBox LinesInCell3(.Cell(2, 3))
End With
End Sub
--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
.
- Follow-Ups:
- Re: How many lines used in a table cell?
- From: Helmut Weber
- Re: How many lines used in a table cell?
- References:
- Re: How many lines used in a table cell?
- From: Helmut Weber
- Re: How many lines used in a table cell?
- From: Jezebel
- Re: How many lines used in a table cell?
- From: Helmut Weber
- Re: How many lines used in a table cell?
- From: Jezebel
- Re: How many lines used in a table cell?
- From: Helmut Weber
- Re: How many lines used in a table cell?
- Prev by Date: Re: error checking
- Next by Date: Observation on post by JGM of 4 Dec 2003
- Previous by thread: Re: How many lines used in a table cell?
- Next by thread: Re: How many lines used in a table cell?
- Index(es):
Relevant Pages
|