Visual Basic (VB6 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!

 

Visual Basic Library

This page was last updated on Saturday, November 24, 2001

Public Function strIndexTableNames(doc As Document) As String ' Procedure : strIndexTableNames ' Description: Return a delimited string with the names of all {Index} table names in the document. ' By: Chris Greaves Inc. ' Inputs: DOCUMENT to be examined. ' Returns: STRING. ' Assumes: None. ' Side Effects: None ' Tested: By the calls below. Dim strResult As String ' Transient result strResult = "" Dim fld As Field For Each fld In doc.Fields If fld.Type = wdFieldIndex Then ' it is am {INDEX} Dim strFieldCodeText As String strFieldCodeText = UCase(fld.Code.Text) Dim iInstr As Integer iInstr = InStr(1, strFieldCodeText, "\F") If iInstr > 0 Then ' it is a named Index (\f "Identifier") Dim strName As String ' It may seem wasteful to use strAlphaOnly here ' But I predict MSWord will break out of the limit of single-letter identifiers, so ... strName = strAlphaOnly(Trim(Right$(strFieldCodeText, Len(strFieldCodeText) - iInstr - 1))) ' Generate a result string where the leading character defines the delimiter in use. strResult = strResult & strcDelimiter & strName Else End If Else End If Next fld strIndexTableNames = strResult 'Sub TESTstrIndexTableNames() '' Create a few {INDEX} fields with the /f switch 'MsgBox strIndexTableNames(ActiveDocument) ' ,B,C,A '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 Monday, November 19, 2001

 

 

Hosted by www.Geocities.ws

1