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

    Doc Var Exists Test in Field Codes (Word 97SR2)

    Is there a way to test (using and IF field code) for the presence of a document variable? What I want is indicated by the psuedo-(field code) code below:

    { if "{ DocumentVariable "DateOne" }" <> "" "{ DocumentVariable "DateOne" }" "{ Date }" }

    In other words, if the docvar DateOne exists, use it here, if not, just use the current date.
    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
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Doc Var Exists Test in Field Codes (Word 97SR2)

    Kevin,

    I'd be using a VBA function to cycle through the collection of varaibles, and compare the name.

    Something like (though I don't have VBA here to check):
    <pre>dim dv as DocumentVariable
    For each dv in Activedocument.DocumentVariables
    if dv.name = "myname" then
    msgbox dv.Value
    end if
    next
    </pre>


    But there's probably a way to do it as a field code
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  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: Doc Var Exists Test in Field Codes (Word 97SR2)

    My guess is there is NO way to do it with an {IF} field code. So, the alternatives are brewing...

    Thanks.
    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
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts

    Re: Doc Var Exists Test in Field Codes (Word 97SR2)

    You might want to take a look at the code in Chris Woodman's document variable handler. I believe it is a part of the Keyboard Organizer template on his site.
    Charles Kyle Kenyon
    Madison, Wisconsin

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

    Re: Doc Var Exists Test in Field Codes (Word 97SR2)

    If my memory serves me right, the code in Chris Woodmans's doc var handler is all WordBasic.

    That's a very nice util, though!

    And, I'm on to a solution using Field Codes!. Stay tuned!
    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>

Posting Permissions

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