View Single Post
 
Old 05-03-2022, 11:51 PM
pfigen@gmail.com pfigen@gmail.com is offline Windows 10 Office 2021
Novice
 
Join Date: May 2022
Posts: 2
pfigen@gmail.com is on a distinguished road
Default How can I re-populate my userform after closing the document?

Hi, my first post here, so please go easy on me

I have a Word document using two separate userforms to fill in information into bookmarks in the main doc. Everything is working fine, the bookmarks are updated and I can re-open the userforms as long as the main doc is not saved and closed. The challenge is that if I close the main doc, and opens it again, I have to fill in all the textboxes in the userform again. Is there a way to make the userform automatically read the bookmarks upon opening?

Here is what I have done so far:

When the doc is opened I have the following code:

Private Sub Document_Open()
UserForm1.Show
UserForm2.Show
End Sub

I can also open the userforms by two command buttons:

Private Sub ShowUserForm1_Click()
UserForm1.Show
End Sub

Private Sub ShowUserForm2_Click()
UserForm2.Show
End Sub

Then, the UserForm1 uses the following code to insert data to a bookmark:

Private Sub OKbutton_Click()
Dim BMClientCompanyName As Range

Set BMClientCompanyName = ActiveDocument.Bookmarks("NameOfClientHeader").Ran ge
BMClientCompanyName.Text = Me.TextBoxClientCompanyName.Value
ActiveDocument.Bookmarks.Add "NameOfClientHeader", BMClientCompanyName

Me.Repaint
UserForm1.Hide


Any support will be highly appreciated!
Reply With Quote