Microsoft Office Tutorials and References
In Depth Information
Creating Word Labels from an Excel Recipient List
Option Explicit¶
' * * * * *¶
Public blnUserCancel As Boolean¶
Sub ShowForm()¶
'Show UserForm¶
blnUserCancel = False¶
End Sub¶
Place the following code in the form module of the form that will use it. Access
this module by double-clicking the form in the Visual Basic Editor (VBE) code
window, or right-clicking the name of the form in the Project window (top left)
of the VBE. To display the form in the VBE code window, double-click the
form's name in the Project window (top left).
Option Explicit¶
' * * * * *¶
Private Sub UserForm_Initialize()¶
'Reset Progress Bar label width¶
Me.lblProgressBar.Width = 0¶
End Sub¶
' * * * * *¶
Private Sub cmdStart_Click()¶
'Disable command button¶
Me.cmdStart.Enabled = False¶
'Call main routine¶
Call StartLabelPrint¶
'It's done. Quit application.¶
Unload Me¶
End Sub¶
' * * * * *¶
Sub StartLabelPrint()¶
'Word objects declaration¶
Dim objApp As Word.Application¶
Dim objDoc As Word.Document¶
Dim objDefDoc As Word.Document¶
'Excel objects declaration¶
Dim objSht As Excel.Worksheet¶
Dim objRng As Excel.Range¶
Dim objRow As Excel.Range¶
'variable declaration¶
Dim lngQTY As Single 'Total label count¶
Dim lngPage As Single 'Word Page count¶
Dim intLabelRow As Integer 'Label row indicator¶
Dim i As Long 'Counter¶
Dim j As Long 'Counter¶
'Variable declarations for progress bar¶
Dim lngJobCount As Long 'Total job count¶
Dim sngUnitWidth As Single 'Unit width for progress bar¶
Search JabSto ::

Custom Search