Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-28-2018, 12:06 AM
jjphg jjphg is offline Struggling with 1st userform/bookmarks Windows 7 64bit Struggling with 1st userform/bookmarks Office 2016
Novice
Struggling with 1st userform/bookmarks
 
Join Date: Jul 2018
Posts: 1
jjphg is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 07-28-2018, 01:00 AM
macropod's Avatar
macropod macropod is offline Struggling with 1st userform/bookmarks Windows 7 64bit Struggling with 1st userform/bookmarks Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 07-29-2018, 03:05 PM
macropod's Avatar
macropod macropod is offline Struggling with 1st userform/bookmarks Windows 7 64bit Struggling with 1st userform/bookmarks Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
Reply



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
Struggling with 1st userform/bookmarks 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

Other Forums: Access Forums

All times are GMT -7. The time now is 06:52 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft