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 boolFieldExists(strFieldCode As String) As Boolean
' Procedure :   boolFieldExists
' Description:  Return TRUE if a field can be found.
' Copyright:    Chris Greaves Inc.
' Inputs:       STRING name of an active document.
' Returns:      BOOLEAN.
' Assumes:      Nothing
' Side Effects:  None.
' Tested:          By the calls shown below.
    ' This is too crude a test for words, but it works.
    Selection.GoTo what:=wdGoToField, Which:=wdGoToFirst, Count:=1, Name:=strFieldCode
    Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
    If Selection.Fields.Count > 0 Then
        boolFieldExists = UCase(strFieldCode) = UCase(Left(Trim(Selection.Fields(1).Code), Len(strFieldCode)))
    Else
        boolFieldExists = False
    End If
'Sub TESTboolFieldExists()
'    MsgBox boolFieldExists("TOC")
'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 boolFieldExists(strFieldCode As String) As Boolean
' Procedure :   boolFieldExists
' Description:  Return TRUE if a field can be found.
' Copyright:    Chris Greaves Inc.
' Inputs:       STRING name of an active document.
' Returns:      BOOLEAN.
' Assumes:      Nothing
' Side Effects:  None.
' Tested:          By the calls shown below.
    ' This is too crude a test for words, but it works.
    Selection.GoTo what:=wdGoToField, Which:=wdGoToFirst, Count:=1, Name:=strFieldCode
    Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
    If Selection.Fields.Count > 0 Then
        boolFieldExists = UCase(strFieldCode) = UCase(Left(Trim(Selection.Fields(1).Code), Len(strFieldCode)))
    Else
        boolFieldExists = False
    End If
'Sub TESTboolFieldExists()
'    MsgBox boolFieldExists("TOC")
'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