Visual Basic (VB and VBA)

Copyright 1999-2001 Christopher Greaves. All rights reserved.
Home Page and email to [email protected]
If in doubt, record a macro and inspect the entrails!

 

 

Please read the DISCLAIMER.

Here is an INDEX to all the procedures.

You will probably need one copy of my GLOBAL DECLARATIONS.



Public Function lngCountLines(rng As Range) As Long
' Procedure :   lngCountLines
' Description:  determine how many lines in a range of text.
' By:               Chris Greaves Inc.
' Inputs:          A range.
' Returns:        LONG count
' Assumes:      Nothing
' Side Effects: None.
' Tested:       By the calls shown below.
    lngCountLines = 0
    If rng.Start = rng.End Then
        lngCountLines = 1
    Else
        Dim lngStart As Long
        Dim lngEnd As Long
        rng.Select
        lngStart = rng.Start
        lngEnd = rng.End
        Selection.Collapse Direction:=wdCollapseEnd
        While Selection.Range.Start > lngStart
            Selection.MoveUp Unit:=wdLine, Count:=1
           Selection.HomeKey Unit:=wdLine, Extend:=wdMove
            lngCountLines = lngCountLines + 1
        Wend
'        lngCountLines = Selection.Information(wdFirstCharacterLineNumber) - lngLines + 1
    End If
End Function

We all knew nothing when we started …
Home Page and Contact Information
Send email to [email protected].
This page was last updated Thursday, November 15, 2001

 

 

Hosted by www.Geocities.ws

1

Visual Basic (VB and VBA)

Copyright 1999-2001 Christopher Greaves. All rights reserved.
Home Page and email to [email protected]
If in doubt, record a macro and inspect the entrails!

 

 

Please read the DISCLAIMER.

Here is an INDEX to all the procedures.

You will probably need one copy of my GLOBAL DECLARATIONS.

Public Function lngCountLines(rng As Range) As Long
' Procedure :   lngCountLines
' Description:  determine how many lines in a range of text.
' By:               Chris Greaves Inc.
' Inputs:          A range.
' Returns:        LONG count
' Assumes:      Nothing
' Side Effects: None.
' Tested:       By the calls shown below.
    lngCountLines = 0
    If rng.Start = rng.End Then
        lngCountLines = 1
    Else
        Dim lngStart As Long
        Dim lngEnd As Long
        rng.Select
        lngStart = rng.Start
        lngEnd = rng.End
        Selection.Collapse Direction:=wdCollapseEnd
        While Selection.Range.Start > lngStart
            Selection.MoveUp Unit:=wdLine, Count:=1
           Selection.HomeKey Unit:=wdLine, Extend:=wdMove
            lngCountLines = lngCountLines + 1
        Wend
'        lngCountLines = Selection.Information(wdFirstCharacterLineNumber) - lngLines + 1
    End If
End Function

We all knew nothing when we started …
Home Page and Contact Information
Send email to [email protected].
This page was last updated Thursday, November 15, 2001

 

 

Hosted by www.Geocities.ws

1