Hi,
Sure you've heard this many time before - I'm struggling with my first userform.
I've created the form, no problem, its a very simple textbox only form (no options/drop-downs etc) with the hope of populating the bookmarks in a word template with the enties in the userform. However after a couple of days findling around, trying to find tutorials that can explain to me what to do (so many start off fine but then throw in terms/code that I have no idea what it means and there is no explaination.
Anyway, what I've done so far is as follows
Private Sub Cancel_Click()
ActiveDocument.Close SaveChanges:=False
End Sub
Private Sub UserForm_Click()
AccountForm.Show
End Sub
Private Sub Submit_Click()
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
Unload Me
End Sub
Now when I click submit in the form when firing up the template nothing happens. The form just sits there and I have to force it to close.
I have come accross this code but I've no idea where I would put it and how I would get it to run/try it after clicking on submit.
Private Sub FillBD(strBMName As String, strValue As String)
Dim orng As Range
With ActiveDocument
Application.ScreenUpdating = False
On Error GoTo lbl_Exit
Set orng = .Bookmarks(strBMName).Range
orng.Text = strValue
orng.Bookmarks.Add strBMName
End With
Application.ScreenUpdating = True
lbl_Exit:
Set orng = Nothing
Exit Sub
Can anybody help me please?
Thanks