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 lngHeadingToIndex(strStyle As String) As Long
    Selection.Find.ClearFormatting
    Selection.Find.Style = ActiveDocument.Styles(strStyle)
    With Selection.Find
        .Text = "^p"
        .Replacement.Text = "^p"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Dim lngCount As Long
    lngCount = 0
    While Selection.Find.Execute
        lngCount = lngCount + 1
        Selection.Paragraphs(1).Range.Select
        Dim strText As String
        strText = Selection.Text
        Selection.Collapse
        Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldIndexEntry, Text:=strText, PreserveFormatting:=False
        Selection.MoveDown Unit:=wdParagraph, Count:=1, Extend:=wdMove
    Wend
    lngHeadingToIndex = lngCount
'Sub TESTlngHeadingToIndex()
'MsgBox lngHeadingToIndex("Heading 1")
'MsgBox lngHeadingToIndex("Heading 2")
'MsgBox lngHeadingToIndex("Heading 3")
'MsgBox lngHeadingToIndex("Heading 4")
'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 lngHeadingToIndex(strStyle As String) As Long
    Selection.Find.ClearFormatting
    Selection.Find.Style = ActiveDocument.Styles(strStyle)
    With Selection.Find
        .Text = "^p"
        .Replacement.Text = "^p"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Dim lngCount As Long
    lngCount = 0
    While Selection.Find.Execute
        lngCount = lngCount + 1
        Selection.Paragraphs(1).Range.Select
        Dim strText As String
        strText = Selection.Text
        Selection.Collapse
        Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldIndexEntry, Text:=strText, PreserveFormatting:=False
        Selection.MoveDown Unit:=wdParagraph, Count:=1, Extend:=wdMove
    Wend
    lngHeadingToIndex = lngCount
'Sub TESTlngHeadingToIndex()
'MsgBox lngHeadingToIndex("Heading 1")
'MsgBox lngHeadingToIndex("Heading 2")
'MsgBox lngHeadingToIndex("Heading 3")
'MsgBox lngHeadingToIndex("Heading 4")
'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