View Single Post
 
Old 01-05-2022, 07:35 AM
mchapa89 mchapa89 is offline Windows 10 Office 2016
Novice
 
Join Date: Jan 2022
Posts: 1
mchapa89 is on a distinguished road
Default Using Option Button to select Recipient in VBA in Word

I have a word document that, upon clicking a button, attaches itself to an email. I have 10 option buttons that I would like the user to choose from, to designate who should receive the email address. How can I change my code to allow the VBA to select the corresponding email address for that option button and send it only to them?

For example, let's say the option buttons were:

-Sally
-Mark

If my user selected Sally, my code would say
"If opt_Sally, then shenderson@fakecompany.com; elseif opt_Mark, then mrichardson@fakecompany.com"
-------------------------------------------


Private Sub CommandButton1_Click()

Dim OL As Object
Dim EmailItem As Object
Dim Doc As Document


Application.ScreenUpdating = False
Set OL = CreateObject("Outlook.Application")
Set EmailItem = OL.CreateItem(olMailItem)
Set Doc = ActiveDocument
Doc.Save

With EmailItem
.Subject = "New Vehicle Equipment Trouble Report"
.To =

.Attachments.Add Doc.FullName
.Display
'.Send

End With
Application.ScreenUpdating = True
Set Doc = Nothing
Set OL = Nothing
Set EmailItem = Nothing
Reply With Quote