#1
|
|||
|
|||
Struggling with 1st userform/bookmarks
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 |
#2
|
||||
|
||||
Cross-posted at: https://social.msdn.microsoft.com/Fo...?forum=worddev
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
||||
|
||||
Now also cross-posted at: http://www.vbaexpress.com/forum/show...not-going-well
Kindly observe the cross-posting etiquette, to which your attention has already been drawn.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Excel Userform to Word Template Bookmarks | JCrinage | Excel Programming | 1 | 11-02-2016 07:03 PM |
Cross Referencing Bookmarks populated from a userform Word 2010 | arbluecreek | Word VBA | 6 | 06-05-2015 05:29 AM |
Form updating Bookmarks - writes to the bookmarks multiple times | PeterPlys | Word VBA | 13 | 01-14-2015 06:41 AM |
Update Bookmarks from a Userform | alshcover | Word VBA | 12 | 01-12-2015 06:53 PM |
Trying to populate Word bookmarks with excel UserForm | smd1112 | Excel Programming | 7 | 09-03-2014 09:42 PM |