1st Attempt at userform - dismal failure :o( RRS feed

  • Question

  • Hi,

    I'm making my first attempt at creating a userform but not having any luck getting it to either run, populate the document or do anything else that's of any help.  I've trawled the web/forums for help but most of the articles are way above my level of understanding with code terms just popping into examples without explaination of what they are or what they do.  Anyway, what I've done so far is create the template, include the bookmarks, created the userform, double and triple checked the template bookmark labels and the VBA bookmark references are correct and then - well run out of ideas.

    Can anybodyhelp.

    It always falls over at the first bookmark reference.  There are no option button drop-downs or the like - just simple textboxes.

    Many thanks

    Private Sub Cancel_Click()
      ActiveDocument.Close SaveChanges:=False

    End Sub

    Private Sub UserForm_Click()
    End Sub

    Private Sub Submit_Click()
       Application.ScreenUpdating = False
       With ActiveDocument
      .Bookmarks("AccountDate").Range.Text = AccountForm.txtAccountDate.Value
      .Bookmarks("Ref").Range.Text = AccountForm.txtRef.Value
      .Bookmarks("PatientAddress").Range.Text = AccountForm.txtPatientAddress.Value
      .Bookmarks("Patientdob").Range.Text = AccountForm.txtPatientdob.Value
      .Bookmarks("PatientID").Range.Text = AccountForm.txtPatientID.Value
      .Bookmarks("PatientMedicareNo").Range.Text = AccountForm.txtPatientMedicareNo.Value
      .Bookmarks("PatientName").Range.Text = AccountForm.txtPatientName.Value
      .Bookmarks("ItemNo1").Range.Text = AccountForm.txtItemNo1.Value
      .Bookmarks("Description1").Range.Text = AccountForm.txtDescription1.Value
      .Bookmarks("NoofPat1").Range.Text = AccountForm.txtNoofPat1.Value
      .Bookmarks("Date1").Range.Text = AccountForm.txtDate1.Value
      .Bookmarks("Charge1").Range.Text = AccountForm.txtCharge1.Value
      .Bookmarks("NoAcc").Range.Text = AccountForm.txtNoAcc.Value
       End With
       Application.ScreenUpdating = True
    End Sub

    Friday, July 27, 2018 9:01 PM

All replies

  • Cross-posted at:
    For cross-posting etiquette, please read:

    Paul Edstein
    [MS MVP - Word]

    Saturday, July 28, 2018 8:00 AM
  • Now also cross-posted at:!st-try-not-going-well

    Kindly observe the cross-posting etiquette, to which your attention has already been drawn.

    Paul Edstein
    [MS MVP - Word]

    Sunday, July 29, 2018 10:06 PM
  • Hello JJPHG,

    Which line caused the error? What's the error message? Are you sure there is a text box named txtAccountDate(or other name is your code) in AccountForm user form?

    I tried to download the template file you shared in another thread. However, it does not contains userform. Could you please share a document with simple userform so we could use it to reproduce your issue?

    For sharing file in MSDN, you could share the file via Cloud Storage, such as One Drive, and then put link address here. Thanks for understanding.

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Monday, July 30, 2018 8:12 AM
  • <<It always falls over at the first bookmark reference.>>

    That doesn't tell us very much. HOW does it "fall over"? Do you get any error message?

    You might try using the .Text propery instead of the .Value  property for the text boxes on the UserForm.

    Cindy Meister, Office Developer/Word MVP, <a href=""> my blog</a>

    Monday, July 30, 2018 4:06 PM