Results 1 to 3 of 3
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    obtain the field type information (OfficeXP SP3)

    Hey there

    I have the following code which goes thru all the fields in a document. if the field type is of type 'DocVariable' then i want to format the field. to keep it simplate i havent yet added that code if the fieldtype is DocVariable is true.
    So far this is my code although it doesnt compile on line
    afield.Type

    any suggestions on how i can obtain the information of the current field type?

    Dim afield As Fields

    For Each afield In ActiveDocument.Fields
    If afield.Type = wdFieldDocVariable Then
    MsgBox afield.Type
    Next afield


    cheers diana

  2. #2
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: obtain the field type information (OfficeXP SP3)

    hey hans

    thanks for that. yes i just worked it out.


    Dim afield As Field
    For Each afield In ActiveDocument.Fields
    If afield.Type = wdFieldDocVariable Then
    MsgBox afield.Type
    MsgBox afield.Code
    End If
    Next afield


    many thanks Diana

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: obtain the field type information (OfficeXP SP3)

    The declaration of afield should be As Field instead of As Fields.

    If you have found a field of type wdFieldDocVariable, you can use afield.Result to get the range corresponding to the field. Example:

    afield.Result.Font.Size = 18

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •