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 intMaxHeadingStyle(strDoc As String) As Integer
' Procedure :   intMaxHeadingStyle
' Description:  Return the maximum level number detected in the open document.
' Copyright: Chris Greaves Inc.
' Inputs:          STRING name of an active document.
' Returns:        Integer "Heading" level number.
' Assumes:      Nothing
' Side Effects:  None.
' Tested:          By the calls shown below.
    intMaxHeadingStyle = 0 ' default result "None found"
    Dim intI As Integer
    For intI = 9 To 1 Step -1 ' Anticipate the maximum, work downwards to despair.
        Selection.Find.ClearFormatting
        Selection.Find.Style = ActiveDocument.Styles("Heading " & Trim(str(intI)))
        With Selection.Find
            .Text = ""
            .Replacement.Text = ""
            .Forward = True
            .Wrap = wdFindContinue
            .Format = True
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
        End With
        If Selection.Find.Execute Then ' Success!!!!
            intMaxHeadingStyle = intI
            Exit Function
        Else
        End If
    Next intI
'Sub TESTintMaxHeadingStyle()
'    MsgBox intMaxHeadingStyle(ActiveDocument.Name)
'End Sub
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 intMaxHeadingStyle(strDoc As String) As Integer
' Procedure :   intMaxHeadingStyle
' Description:  Return the maximum level number detected in the open document.
' Copyright: Chris Greaves Inc.
' Inputs:          STRING name of an active document.
' Returns:        Integer "Heading" level number.
' Assumes:      Nothing
' Side Effects:  None.
' Tested:          By the calls shown below.
    intMaxHeadingStyle = 0 ' default result "None found"
    Dim intI As Integer
    For intI = 9 To 1 Step -1 ' Anticipate the maximum, work downwards to despair.
        Selection.Find.ClearFormatting
        Selection.Find.Style = ActiveDocument.Styles("Heading " & Trim(str(intI)))
        With Selection.Find
            .Text = ""
            .Replacement.Text = ""
            .Forward = True
            .Wrap = wdFindContinue
            .Format = True
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
        End With
        If Selection.Find.Execute Then ' Success!!!!
            intMaxHeadingStyle = intI
            Exit Function
        Else
        End If
    Next intI
'Sub TESTintMaxHeadingStyle()
'    MsgBox intMaxHeadingStyle(ActiveDocument.Name)
'End Sub
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