Re: How many lines used in a table cell?

Tech-Archive recommends: Speed Up your PC by fixing your registry



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"


.



Relevant Pages

  • Re: Create Right Click Option to Copy Cell Address
    ... have moved to a cell value. ... Private Sub Workbook_BeforeClose ... Dim MyDataObj As New DataObject ... Dim ctrl As CommandBarControl ...
    (microsoft.public.excel.programming)
  • Re: CompareValues
    ... Sub DateFileSave() ... Dim yourFilename As String ... perhaps by simple expedient of selecting that cell before ... interest is in column A - declared by constant SearchColumn in each routine: ...
    (microsoft.public.excel.misc)
  • Re: Auto Row Height in Merged Cells with pre exisiting text
    ... "Dave Peterson" wrote: ... Private Sub Worksheet_Change ... the largest cell and click...just won't do it automatically? ... Dim cWdth As Single, MrgeWdth As Single ...
    (microsoft.public.excel.programming)
  • Re: Auto Row Height in Merged Cells with pre exisiting text
    ... "Dave Peterson" wrote: ... Private Sub Worksheet_Change ... the largest cell and click...just won't do it automatically? ... Dim cWdth As Single, MrgeWdth As Single ...
    (microsoft.public.excel.programming)
  • Re: How to capture Max cell value (High Water Mark)
    ... Where A1 is the cell that is changing and the HiWater function can be in any ... I don't have any other macros in the workbook. ... Sub Test_Enable_Events ... I'm only using it on the same worksheet where the macro was created. ...
    (microsoft.public.excel)