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 RemoveNamedFields(doc As Document, intFieldType As Integer, strIdentifer As String) As String
' Procedure :   RemoveNamedFields
' Description:  Remove all occurrences of the named field from the document
' By:           Chris Greaves Inc.
' Inputs:       DOCUMENT to be examined, field type and identifier.
' Returns:      None.
' Assumes:      None.
' Side Effects: None
' Tested:       By the calls below.
    Dim fld As Field
    For Each fld In doc.Fields
        If fld.Type = intFieldType Then
            Dim strFieldCodeText As String
            strFieldCodeText = UCase(fld.Code.Text)
            Dim iInstr As Integer
            iInstr = InStr(1, strFieldCodeText, "\F")
            If iInstr > 0 Then
                Dim strName As String
                strName = Trim(Right$(strFieldCodeText, Len(strFieldCodeText) - iInstr - 1))
                strName = Left$(strName, 1)
                If UCase(strIdentifer) = UCase(strName) Then
                    fld.Select
                    fld.Delete
                 Else
                 End If
            Else
            End If
        Else
        End If
    Next fld
'Sub TESTstrFieldNames()
'Call RemoveNamedFields(ActiveDocument, wdFieldIndex, "a")
'Call RemoveNamedFields(ActiveDocument, wdFieldIndexEntry, "X")
'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 RemoveNamedFields(doc As Document, intFieldType As Integer, strIdentifer As String) As String
' Procedure :   RemoveNamedFields
' Description:  Remove all occurrences of the named field from the document
' By:           Chris Greaves Inc.
' Inputs:       DOCUMENT to be examined, field type and identifier.
' Returns:      None.
' Assumes:      None.
' Side Effects: None
' Tested:       By the calls below.
    Dim fld As Field
    For Each fld In doc.Fields
        If fld.Type = intFieldType Then
            Dim strFieldCodeText As String
            strFieldCodeText = UCase(fld.Code.Text)
            Dim iInstr As Integer
            iInstr = InStr(1, strFieldCodeText, "\F")
            If iInstr > 0 Then
                Dim strName As String
                strName = Trim(Right$(strFieldCodeText, Len(strFieldCodeText) - iInstr - 1))
                strName = Left$(strName, 1)
                If UCase(strIdentifer) = UCase(strName) Then
                    fld.Select
                    fld.Delete
                 Else
                 End If
            Else
            End If
        Else
        End If
    Next fld
'Sub TESTstrFieldNames()
'Call RemoveNamedFields(ActiveDocument, wdFieldIndex, "a")
'Call RemoveNamedFields(ActiveDocument, wdFieldIndexEntry, "X")
'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