Hi,
I am new to this and trying to teach myself VBA as I go. My challenge is, I have created a Microsoft Word Template. My template has a number of questions it asks the user, and then populates the results into various bookmarks in a document.
One of the questions is to select which governance committee will be overseeing a project. I did have the entry originally as a text box function, but thought I would use a combo box to limit the values. I created the combo box, it has
the values I want and looks okay. My issue is - how do I have the selected entry from the combo box, post to an assigned bookmark.
The code I am using is
Private Sub B_Committee_Change()
End Sub
' combo box values
Private Sub B_Committee_DropButtonClick()
B_Committee.List = Array("Executive Board", "Finance and Operations Committee", "People and Culture Committee", "Risk and Audit Committee", "Performance and Assurance Committee", "other")
End Sub
' Cancel button action for form - just hide it
Private Sub CnclButton_Click()
B_Info_ProjInfo.Hide
End Sub
' populating the text box values on the forms, and assinign them to bookmarks
' this code is clumsy but works - the bookmark in word is defined twice and data entered into field is used once. For this reason there are two dim and two set codes referring to the same text box - wop
' define and declare fields on the form
Private Sub OKButton_Click()
' Proejct Name
Dim B_Project_Name As Range
Set B_Project = ActiveDocument.Bookmarks("B_Project").Range
B_Project.Text = Me.TextBox1.Value
Dim Project As Range
Set Project = ActiveDocument.Bookmarks("Project").Range
Project.Text = Me.TextBox1.Value
' sponsor name to bokmark
Dim B_Sponsor As Range
Set B_Sponsor = ActiveDocument.Bookmarks("B_Sponsor").Range
B_Sponsor.Text = Me.TextBox2.Value
Dim Sponsor As Range
Set Sponsor = ActiveDocument.Bookmarks("Sponsor").Range
Sponsor.Text = Me.TextBox2.Value
' project champion name
Dim B_Champion As Range
Set B_Champion = ActiveDocument.Bookmarks("B_Champion").Range
B_Champion.Text = Me.TextBox3.Value
Dim Champion As Range
Set Champion = ActiveDocument.Bookmarks("Champion").Range
Champion.Text = Me.TextBox3.Value
'Assign champion name to two bookmarks
Dim B_Manager As Range
Set B_Manager = ActiveDocument.Bookmarks("B_Manager").Range
B_Manager.Text = Me.TextBox4.Value
Dim Manager As Range
Set Manager = ActiveDocument.Bookmarks("Manager").Range
Manager.Text = Me.TextBox4.Value
' Assign Financial Governance to two bookmarks
Dim B_FGOV As Range
Set B_FGOV = ActiveDocument.Bookmarks("B_FGov").Range
B_FGOV.Text = Me.TextBox5.Value
Dim CFO As Range
Set CFO = ActiveDocument.Bookmarks("CFO").Range
CFO.Text = Me.TextBox5.Value
' this is the bookmark i want to link the combo box to
Dim B_Committee As Range
Set B_Committee = ActiveDocument.Bookmarks("B_Committee").Range
B_Committee.Text = Me.TextBox6.Value
' hide this form and open the next form
Me.Repaint
B_Info_ProjInfo.Hide
C_Admin_Consulted.Show
End Sub
Private Sub Previous_Click()
B_Info_ProjInfo.Hide
A_Welcome.Show
End Sub
Private Sub TextBox6_Change()
End Sub
Any guidance would be appreciated.. Warren