Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-05-2022, 07:35 AM
mchapa89 mchapa89 is offline Using Option Button to select Recipient in VBA in Word Windows 10 Using Option Button to select Recipient in VBA in Word Office 2016
Novice
Using Option Button to select Recipient in VBA in Word
 
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
  #2  
Old 01-05-2022, 10:28 PM
gmayor's Avatar
gmayor gmayor is offline Using Option Button to select Recipient in VBA in Word Windows 10 Using Option Button to select Recipient in VBA in Word Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,138
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

See attached. Save the document as a macro enabled template and create new documents from it.
Attached Files
File Type: docm Report.docm (26.7 KB, 8 views)
__________________
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
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
send to email recipient option wont work tomer Outlook 0 03-28-2019 07:32 AM
Using Option Button to select Recipient in VBA in Word Mail Merge using edit recipient list option not working properly Dsr122076 Mail Merge 1 12-03-2015 04:19 PM
Setting a particular table cell background color when an option button is selected in Word 2007 a888 Word VBA 11 03-25-2015 05:33 AM
Using Option Button to select Recipient in VBA in Word Option Button help ksigcajun Word VBA 1 01-15-2015 01:36 PM
Help on option button active X aligahk06 Excel 0 11-03-2009 11:39 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:42 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft