Results 1 to 4 of 4
  1. #1
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Test for Doc Property Field (Word 97SR2)

    I need code that tests for the presence of a specific document property field in a document.

    If DocRefExists("NameOfPropertyReferencedByField) then...

    Anyone know the syntax?
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Test for Doc Property Field (Word 97SR2)

    If nothing else comes to mind, you could loop through the Fields collection:

    Dim fld As Field
    For Each fld In ActiveDocument.Fields
    If InStr(1, fld.Code.Text, "DOCPROPERTY ""Author""", vbTextCompare) Then
    Debug.Print "Woohoo"
    Exit For
    End If
    Next

    I don't know whether this will get fields from all the nooks and crannies, or only the main "Story."

  3. #3
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Test for Doc Property Field (Word 97SR2)

    Jefferson,

    That's what I thought. When the document has a table of contents and TOA that for loop hits every stinkin' field ref. I was hoping to avoid that noticeable delay.

    Is there no way to Find or Goto an exact Document Property reference. If the find or goto fails, the error condition can be trapped?

    Thanks for your help.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Test for Doc Property Field (Word 97SR2)

    Word's interactive Find will find text inside field codes if they are toggled to display. I haven't experimented with the Find object in code. You should try it and see if it is any more efficient than the looping.

Posting Permissions

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