Results 1 to 7 of 7
  1. #1
    Star Lounger
    Join Date
    Jan 2003
    Location
    San Francisco, California, USA
    Posts
    93
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Document Variables - Scope (Word 2000 or Word 2002)

    Hello,

    Could someone please tell me what the scope of a document variable is? Does it always remain with the document or is it deleted when I close the document. I'm attempting to compare a document variable to the keywords field to identify if the end-user has increased the version number. If so I then prompt them with a SaveAs dialog. I'm finding that the variable is sometimes deleted.

    by document variable i mean:

    activedocument.variables.add Name:="Version", Value:="0.1".

    Thank you,

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Document Variables - Scope (Word 2000 or Word 2002)

    They live for the life of the document. I note that you are using ActiveDocument, which can sometimes be pointing to a different document to the one that you thought it was!

    StuartR

  3. #3
    Star Lounger
    Join Date
    Jan 2003
    Location
    San Francisco, California, USA
    Posts
    93
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Document Variables - Scope (Word 2000 or Word 2002)

    Hi Stuart,

    Thanks for the response. I'm curious, what else would be better besides activedocument?

  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: Document Variables - Scope (Word 2000 or Word 2002)

    You'll be wanting to read this thread on why it often is better to assign a document object variable to a document rather than rely on it being the active document (or activating it).

  5. #5
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Document Variables - Scope (Word 2000 or Word 2002)

    Hi Kyle

    It's very easy to inadvertently delete a docvar by setting its value to an empty string. This has the same effect as .Delete - it removes it from the collection. By contrast, a bookmark will remain in the bookmark collection regardless of its value. If you don't keep this in mind when programming, you can run into unexpected and unwelcome errors... that must be redundant - I can't think of any errors that aren't unwelcome. <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    Alan

  6. #6
    Star Lounger
    Join Date
    Jan 2003
    Location
    San Francisco, California, USA
    Posts
    93
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Document Variables - Scope (Word 2000 or Word 2002)

    Thanks Alan. I think this is what is also happening to me.

  7. #7
    Star Lounger
    Join Date
    Jan 2003
    Location
    San Francisco, California, USA
    Posts
    93
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Document Variables - Scope (Word 2000 or Word 2002)

    Thanks this is helpful!

Posting Permissions

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