none
Word DOCVARIABLE Question RRS feed

Answers

  • Did you update the DocVariable field?

    Private Sub Btn1_Click()
         ActiveDocument.Variables("GradsName") = "Whatever"
         MsgBox ActiveDocument.Variables("GradsName").Value  ' I included this statement for a check only
         ActiveDocument.Fields.Update
     End Sub


    Greg Maxey Please visit my website at: http://gregmaxey.mvps.org/word_tips.htm

    Saturday, February 2, 2013 7:02 PM

All replies

  • Like this:

      ' Prevent document variable from being deleted
      If Me.txtSubject = "" Then Me.txtSubject = " "
      ActiveDocument.Variables("Subject") = Me.txtSubject


    Regards, Hans Vogelaar

    Saturday, February 2, 2013 4:45 PM
  • Sorry, but that doesn't work either. This is what I am doing:

    1. open up Word -- so there is a blank document that appears.

    2. I manually insert a DOCVARIABLE that I name GradsName.

    3. I have a macro that contains a Form with one textbox -- fieldname is also GradsName, and one button.

    4. I type in a persons name and click the button (in the hopes that the textbox value will be inserted in the DOCVARIABLE) in the open document.

    5. here's my code:

    Private Sub Btn1_Click()
        ActiveDocument.Variables("GradsName") = GradsName.Value
        MsgBox (GradsName.Value)  ' I included this statement for a check only
    End Sub

    Any ideas?

    Saturday, February 2, 2013 6:41 PM
  • Did you update the DocVariable field?

    Private Sub Btn1_Click()
         ActiveDocument.Variables("GradsName") = "Whatever"
         MsgBox ActiveDocument.Variables("GradsName").Value  ' I included this statement for a check only
         ActiveDocument.Fields.Update
     End Sub


    Greg Maxey Please visit my website at: http://gregmaxey.mvps.org/word_tips.htm

    Saturday, February 2, 2013 7:02 PM
  • Thank you Greg!  That did it.

    Saturday, February 2, 2013 8:55 PM