Microsoft Office Tutorials and References
In Depth Information
Entering Data Easily Using a Custom Dialog Box
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 below for
reference.
View the Appendix to learn how to store this procedure
in a UserForm.
Option explicit¶
' * * * * *¶
Private Sub btnCancel_Click()¶
Me.Hide¶
Me.Tag = "Cancel"¶
End Sub¶
' * * * * *¶
Private Sub btnOK_Click()¶
Me.Hide¶
Me.Tag = "OK"¶
End Sub¶
Wrd
The code in the example file also includes the 'basCreateBookmark' module,
which is utilized in the Creating a Bookmark from a Selection entry found 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¶
Search JabSto ::




Custom Search