Microsoft Office Tutorials and References
In Depth Information
Filling a Word Combo Box with Data from Excel
Follow these steps:
1. Copy the macro code to the correspondence template's VBA project.
2. Transfer the UserForm frmUserInput to the same project using either
the Organizer, or by dragging it in the Visual Basic Editor (VBE) to the
template's project. The code for this UserForm module is as follows.
View the Appendix to learn how to store this procedure
in a UserForm (in Word).
Option explicit¶
' * * * * *¶
Private Sub btnCancel_Click()¶
Me.Hide¶
Me.Tag = "Cancel"¶
End Sub¶
' * * * * *¶
Private Sub btnOK_Click()¶
Me.Hide¶
Me.Tag = "OK"¶
End Sub¶
The code in the example file also includes the module 'basCreateBookmark',
which is utilized in the Creating a Bookmark from a Selection entry on page
260. It is included below for reference.
Option explicit¶
' * * * * *¶
Const varName As String = "BookmarkCounter"¶
Const varDuplicateName As String _¶
= "DuplicateBookmarkCounter"¶
' * * * * *¶
Sub CreateBookmark()¶
'Variable declaration¶
Dim rng As Word.Range¶
Dim BookmarkName As String¶
Dim var As Word.Variable¶
'Check whether the document variable that stores¶
'a counter for bookmarks without content exists¶
If varExists(ActiveDocument, varName) = False Then¶
'If not, create it and assign it the value 1¶
ActiveDocument.Variables.Add _¶
Name:=varName, Value:="1"¶
End If¶
Set var = ActiveDocument.Variables(varName)¶
Set rng = Selection.Range¶
If Selection.Type = wdSelectionIP Then¶
Cmb
Search JabSto ::




Custom Search