Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a list of names which i present in a combo box on the userform.
I have an email textbox. I want the email to be auto-populated based on the name chosed. May I ask your help with this? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Jerry, Only the first procedure is really relevant in this post the
others are to show how you may want to call it but, that entirely depends on your needs. Private sub BuildAndSend has 4 required parameters €śToWhom€ť, €śSubject€ť,€ťBody€ť, and €śSend€ť. Pass the appropriate values to the procedure and it will send or display an email to the user to send. HTH. Private Sub BuildAndSend( _ ByVal ToWhom As String, _ ByVal Subject As String, _ ByVal Body As String, _ ByVal Send As Boolean) Dim Outlook As Object Dim Mail As Object Set Outlook = CreateObject("Outlook.Application") Outlook.Session.Logon Set Mail = Outlook.CreateItem(0) With Mail .to = ToWhom .Subject = Subject .Body = Body If Send = True Then .Send Else .Display End If End With Set Outlook = Nothing Set Mail = Nothing End Sub Private Sub ComboBox1_Change() Select Case ComboBox1.Value Case "Paul" Call ", "annual bonus", "Hi Paul your annaul bonus is $1000", False) Case "John" Call ", "annual bonus", "Hi John your annaul bonus is $2000", False) Case "George" Call ", "annual bonus", "Hi George your annaul bonus is $3000", False) Case "Ringo" Call ", "annual bonus", "Hi Ringo your annaul bonus is $4000", False) End Select End Sub Private Sub UserForm_Initialize() Dim NameArray As Variant Dim I As Long NameArray = Array("Paul", "John", "George", "Ringo") For I = LBound(NameArray) To UBound(NameArray) ComboBox1.AddItem NameArray(I) Next End Sub "Jerry" wrote: I have a list of names which i present in a combo box on the userform. I have an email textbox. I want the email to be auto-populated based on the name chosed. May I ask your help with this? . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Auto Populate Date when specific entry is chosen from data validation | Excel Worksheet Functions | |||
Populate combo box, then hide rows that don't match chosen value | Excel Programming | |||
How do I create an email macro to auto fill the email? | Excel Discussion (Misc queries) | |||
Auto-filtering based on a value chosen in a combo box? | Excel Discussion (Misc queries) | |||
Auto-populate, Auto-copy or Auto-fill? | Excel Worksheet Functions |