
04-06-2016, 05:06 AM
|
Advanced Beginner
|
|
Join Date: Mar 2016
Posts: 37
|
|
Quote:
Originally Posted by gmayor
Code:
Option Explicit
Private Sub CANCELbutton_Click()
Me.Hide
Me.Tag = 0
End Sub
Private Sub OKbutton_Click()
Me.Hide
Me.Tag = 1
End Sub
is what goes in the userform code module. This hides the userform and passes the control to the calling macro Sub Main() which continues based on the value of Me.Tag.
The parts that you added to the above go in the code that calls the userform e.g. as follows. The Excel function also goes in the same module as Sub Main.
Code:
Sub Main()
Dim oFrm As New DrawingNumberEntryForm
With oFrm
xlFillList ListOrComboBox:=.DrawingNumberUf, _
iColumn:=1, _
strWorkbook:="C:\Temp\ItemSheet.xlsx", _
strRange:="CollRange", _
RangeIsWorksheet:=False, _
RangeIncludesHeaderRow:=True
.Show
If .Tag = 0 Then GoTo lbl_Exit 'Cancel was selected
ActiveDocument.SelectContentControlsByTitle("Drawing Number").Item(1).Range.Text = .DrawingNumberUf.Text
End With
lbl_Exit:
Unload oFrm
Set oFrm = Nothing
Exit Sub
End Sub
|
Gotcha!
I'll give it a try.
|