Finding Seq fields via macro?

M

ML

I have a document that contains a number of custom seq fields that are used
for classification markers throughout my document. These handle page level
header flags that check for the markers and set a related header text. This
is all working fine.

What I would like to do now is have a macro that would also check for these
seq field and give me a count of each type in use or at least confirm that a
seq is used.

There are a number of these different seq codes and I need to find which
ones are used somewhere within the document.

What would be the simplest way to do this in code?

Here is a sample seq that is inserted in the document body:
{QUOTE (C) { SEQ C \r {PAGE \h }}
 
G

Greg Maxey

ML,

Maybe something like:

Sub Scratchmacro()
Dim oFld As Field
Dim C As Integer
Dim S As Integer

For Each oFld In ActiveDocument.Fields
If oFld.Type = wdFieldSequence Then
If InStr(oFld.Code.Text, "SEQ C") > 0 Then C = C + 1
If InStr(oFld.Code.Text, "SEQ S") > 0 Then S = S + 1
End If
Next
MsgBox ("There are " & C & " SEQ C fields and " & S & " SEQ S Fields")
End Sub
 
M

ML

Yes that is exactly what I ended up doing actually. Seems to work for my
needs.
Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top