• Form letters using input box (2002)

    Author
    Topic
    #438524

    I have no experience with word automation, except replacing bookmarks from Access. I have a simple form letter that I would like to have input boxes prompt for various information, and then populate the letter (sometimes in multiple areas) with the data provided. Databasing the info isn’t necessary, since it’s going to be used once and thrown away. Any guidance would be greatly appreciated.

    Viewing 0 reply threads
    Author
    Replies
    • #1046159

      I figured it out. Here’s the code if anyone else wants to use it:

      ‘note that naming a sub AutoOpen will cause it to automatically execute when the document is opened
      Sub AutoOpen()
      ‘Check to see if the first bookmark exists. If not, the document has be saved, and you don’t want input prompts
      If ActiveDocument.Bookmarks.Exists(“bkAddressee”) = True Then

      ‘declare your variables. Each string is a bookmark that was inserted in the word document.
      Dim strAddress1 As String
      Dim strAddress2 As String
      Dim strAddressee As String

      ‘define your string
      strAddressee = InputBox(“Enter addressee title:”)

      ‘select your bookmark
      ActiveDocument.Bookmarks(“bkAddressee”).Select

      ‘and then replace it
      Selection.Text = strAddressee

      strAddress1 = InputBox(“Enter street address:”)
      ActiveDocument.Bookmarks(“bkAddress1”).Select
      Selection.Text = strAddress1

      strAddress2 = InputBox(“Enter city, state, and zip:”)
      ActiveDocument.Bookmarks(“bkAddress2”).Select
      Selection.Text = strAddress2

      Else
      ‘do nothing
      End If

      End Sub

    Viewing 0 reply threads
    Reply To: Form letters using input box (2002)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: