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 NoSplit(rngTbl As Range)
' Procedure:    cmd_NoSplit
' Description:  Keep all lines of a table together with the preceding paragraph.
' By:           Chris Greaves Inc.
' Inputs:       None.
' Returns:      None.
' Assumes:      None.
' Side Effects: Page layout may change.
' Tested:       By a call from the user.
    ' We want to mark "Keep With next" for the paragraph of text preceding the table,
    '   and all rows but the last of the table.
    Dim rngKeep As Range ' Range object used to locate the necessary text.
    If rngTbl.Information(wdWithInTable) Then
        If rngTbl.Tables(1).Rows.Count > 1 Then ' more than one row, so look for the penultimate.
            Set rngKeep = rngTbl.Tables(1).Rows(rngTbl.Tables(1).Rows.Count - 1).Range
            Dim lngEnd As Long
            lngEnd = rngKeep.End
            Set rngKeep = rngTbl.Tables(1).Rows(1).Range
        Else ' only one row, so deal with the first
            Set rngKeep = rngTbl.Tables(1).Rows(1).Range
            lngEnd = rngKeep.Start - 1 ' make the end to be the end of the paragraph of text.
        End If
'Procs        Dim lngStart As Long
        rngKeep.Start = rngKeep.Start - 1 ' go back one character into the preceding non-table paragraph.
        rngKeep.End = lngEnd
        rngKeep.ParagraphFormat.KeepWithNext = True
    Else
        Call errMustBeInTable
    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 NoSplit(rngTbl As Range)
' Procedure:    cmd_NoSplit
' Description:  Keep all lines of a table together with the preceding paragraph.
' By:           Chris Greaves Inc.
' Inputs:       None.
' Returns:      None.
' Assumes:      None.
' Side Effects: Page layout may change.
' Tested:       By a call from the user.
    ' We want to mark "Keep With next" for the paragraph of text preceding the table,
    '   and all rows but the last of the table.
    Dim rngKeep As Range ' Range object used to locate the necessary text.
    If rngTbl.Information(wdWithInTable) Then
        If rngTbl.Tables(1).Rows.Count > 1 Then ' more than one row, so look for the penultimate.
            Set rngKeep = rngTbl.Tables(1).Rows(rngTbl.Tables(1).Rows.Count - 1).Range
            Dim lngEnd As Long
            lngEnd = rngKeep.End
            Set rngKeep = rngTbl.Tables(1).Rows(1).Range
        Else ' only one row, so deal with the first
            Set rngKeep = rngTbl.Tables(1).Rows(1).Range
            lngEnd = rngKeep.Start - 1 ' make the end to be the end of the paragraph of text.
        End If
'Procs        Dim lngStart As Long
        rngKeep.Start = rngKeep.Start - 1 ' go back one character into the preceding non-table paragraph.
        rngKeep.End = lngEnd
        rngKeep.ParagraphFormat.KeepWithNext = True
    Else
        Call errMustBeInTable
    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