Re: Parsing Fields in VBA code by DaveLett
DaveLett
Mon Jan 23 07:42:03 CST 2006
Hi ML,
Yes, there is an easy way to get the page number of a field. Here's an
example:
For Each oFld In ActiveDocument.Fields
Debug.Print oFld.Result.Information(wdActiveEndPageNumber)
Next oFld
HTH,
Dave
"ML" wrote:
> Thanks. As this is looping, is there an easy means to determine what page
> the current field is on? I need to determine the page that each field is
> found on in order to handle some additional processing.
>
> So basically the user inserts these custom quote fields. At some later time
> a macro parses the document, as it find each field it then saves a variable
> to indicate something nit has found in relation to the page it was found on.
>
> Can I determine the page easily?
>
> "Dave Lett" <DaveLett@discussions.microsoft.com> wrote in message
> news:8FCDBCDB-81A2-4862-9467-A58C3C3CFB38@microsoft.com...
> > Hi ML,
> >
> > You might be able to use something like the following:
> >
> > Dim oFld As Field
> > Dim sFldText As String
> > Dim sFldCode As String
> > For Each oFld In ActiveDocument.Fields
> > If oFld.Type = wdFieldQuote Then
> > sFldCode = oFld.Code.Text
> > '''strip unneeded material
> > sFldText = sFldText & Mid(sFldCode, 9, Len(sFldCode) - 25) & vbCrLf
> > End If
> > Next oFld
> > Debug.Print sFldText
> >
> > If you're not sure about what the field code might be, then you could
> > change
> > the MID function to test for "extra" material by using the InStr function.
> >
> > HTH,
> > Dave
> >
> > "ML" wrote:
> >
> >> I have a document that will have fields inserted by the user. Somehow I
> >> need to allow the user to insert text in these fields that is freeform,
> >> the
> >> only way I guess this can be done is via the fields add method. Assuming
> >> I
> >> can do this in code, and set the user text as the QUOTE section of the
> >> field, is there some means that I can later parse the document for a
> >> given
> >> field code, and then strip out the QUOTE text in code?
> >>
> >>
> >>
>
>
>