Results 1 to 8 of 8

Thread: [RESOLVED] Persistent document variables VBA word

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    4

    Resolved [RESOLVED] Persistent document variables VBA word

    I'm setting a document variable in msWord.

    I can set it.
    Delete it.
    Reset it.
    Read the value of it.

    But I don't know how to tell if it already exists????
    Last edited by Hack; May 31st, 2006 at 06:58 AM. Reason: Added [RESOLVED] to thread title Last edited by gkukurin : Yesterday at 05:19 PM. Reason: Resloved

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Persistent document variables VBA word



    this goes in the Office Development


    Word is the only Office app I have little exp with programming..
    is there a "variable" object?
    like ThisDocument.Variable.Count?
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Persistent document variables VBA word

    G'Day gkukurin, Welcome to the Forum

    How have you set the variable? Can you post the code you used (if you did it in code)?

  4. #4

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    4

    Re: Persistent document variables VBA word

    'This code creates a doc_var called <Fullname>
    'And sets the doc_var value to the value of a textbox


    Private Sub CommandButton5_Click()

    ActiveDocument.Variables.Add Name:="FULLNAME", Value:= txtINDI.Text

    End Sub

  5. #5

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    4

    Re: Persistent document variables VBA word

    Static...

    You're right on!!!

    Yes I can obtain a count and this in turn gives me the info I need to
    determine how many, if any variables exist.

    Thanks!!!!

    GK

  6. #6
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Persistent document variables VBA word

    As an alternative to .Count, you could use the Variables Collection like:
    VB Code:
    1. Dim objVar As Variable
    2. For Each objVar In ActiveDocument.Variables
    3.     MsgBox "Name =" & objVar.Name & vbCr & "Value = " & objVar.Value
    4. Next

  7. #7

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    4

    Re: Persistent document variables VBA word

    Thanks All!!!

  8. #8
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Persistent document variables VBA word

    Yeah Burce... thats where I was headed... if there was a variables collection (object) then u could loop through

    Glad it worked!
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

Posting Permissions

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



Click Here to Expand Forum to Full Width