View Single Post
 
Old 02-26-2015, 10:43 PM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,142
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

OK, then add a text box to the aforementioned userform and modify the code associated with the OK button as follows:
Code:
Private Sub btnOK_Click()
Dim bSelected As Boolean
Dim i As Long
    With Me
        If .TextBox1.Text = "" Then
            MsgBox "Enter the title"
            .TextBox1.SetFocus
            GoTo lbl_Exit
        End If
        For i = 0 To .ListBox1.ListCount - 1
            If .ListBox1.Selected(i) Then
                bSelected = True
                Exit For
            End If
        Next i
        If Not bSelected Then
            MsgBox "Select at least one item from the list"
            .ListBox1.SetFocus
            GoTo lbl_Exit
        End If
        .Hide
        .Tag = 1
    End With
lbl_Exit:
    Exit Sub
End Sub
The modify the names of each of your macros to enable the title from the text box to be passed e.g.
Code:
Sub Add_Att1(strTitle As String)
and then replace Title in your code with strTitle e.g.
Code:
Selection.TypeText Text:="Attachment 1 – " & strTitle
That will then insert the selected title where indicated. If your macros worked correctly before, then they should do so with the addition of the titles entered.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote