Combo Box

Status
Not open for further replies.

LMS

Senior Member
Outlook version
Email Account
Exchange Server
To summarze the past, please see below for the next possible steps

I have found through great advice , a way to create set of email templates and a form of macro that when I single click on a contact in contact folder list, when I run the macro it creates an email based on the email template added to the macro and automatically adds the email address of the contact to the "To" bar of the email, so it automatically is set up to send the email to the contact I click on.

Then I found a way to create a new menu bar as part of Outlook when you open Outlook, and add each macro as a part of menu bar so that when I click on the menu bar, I see a drop down list of each macro I can run, and if I have clicked on a contact (but not opening it), when I run the macro from the new menu bar, it does the same thing I mentioned above.

In the contact template I created, I can add each macro to the Quick Access Toolbar, which creates a bullet in the contacts for each macro, and then when opening the contact, I can do the same as mentioned above as well.

I have been told that there is no way to create a new menu bar in the contact template or a drop down list, so I don't have to have a long horizontel list of bullets to run the macros when I open a contact, , but have the new menu/drop down list just like it works in the new menu bar as part of Outlook when you open Outlook.

So here is the next question:

Under the contact template, you can include a Combo Box, so you create your own text field for the Combo Box, the List Type is a Dropdown, the Property t use is Value, and then under Possbile Values, you can type in a series of words and as each line words is separated by a ; each list of words shows up as a dropdown list to decide what to put in the field under your contact.

So is there way under the Como Box , to put in the line of words which then when you on words, it runs a macro?

Thanks to all.
 
I have not used combobox with macros, but they use case statements so you should be able to. The lady has a code sample at Select from a list of subjects before sending a message - Slipstick Systems that should point you in the right direction.

Dim your object at the beginning -

Dim oItem as Outlook.MailItem

put this in the case statement -

Set oItem = Application.CreateItem("C:\template.oft")

put this is at the end of the case -

oItem .Display

You could use the case to assign variables, something like this:
Case 0
strTemplate = "templatename0"
Case 1
strTemplate = "templatename1"

Dim oItem as Outlook.MailItem

Set oItem = Application.CreateItem("C:\path\to\template\" & strTemplate & ".oft")

oItem .Display
 
thanks for quick reply...but I can't figure out what and where you a telling me to add and what the other link says....all i did was create the UserForm1, add the combobox to his with the Caption Field named E-mail Template List, but I don't know what code to add, and how I add each macro....and then how find this UserForm1 on a Contact form...

can you walk me thru this please so much!!

Thanks
 
Have not tested Larry's suggestion but it looks good. If you are using a custom form with the combobox, you can use similar code. Create a button for NewMessageUsingTemplate macro and click it to call the userform and select templates.

Private Sub Userform1_Initialize()
ComboBox1.AddItem "Template 1"
ComboBox1.AddItem "Template 2"
ComboBox1.AddItem "Template 3"
ComboBox1.AddItem "Template 4"
ComboBox1.AddItem "Template 5"

End Sub

Private Sub CommandButton1_Click()
lstNo = ComboBox1.ListIndex
Unload Me

End Sub

Public lstNo As Long

Public Sub NewMessageUsingTemplate()

Dim oMail As Outlook.MailItem
oMail.Display

UserForm1.Show
Select Case lstNo
Case -1
strTemplate = "templatename0"
Case 0
strTemplate = "templatename1"
Case 1
strTemplate = "templatename2"
End Select

Set oMail = Application.CreateItemFromTemplate("C:\path\to\template\" & strTemplate & ".oft")
oMail .Display

End Sub
 
Thanks so much. So this the code that I use for the UserForm1....where is says to create a code?

And how do I create that button on the Contact?

And as to the ComboBox1.AddItem "Template 1" areas, use the name of the macros or the template so that's what shows up?

And as to areas: strTemplate = "templatename0"
Case 0
strTemplate = "templatename1"
Case 1
strTemplate = "templatename2"

Put in the name of the macro's or the name of the template?
 
This: strTemplate = "templatename1" will use the template file name.

Are you calling templates up or using macros to do something and open a template?

oh, and the proper way to call a template is with CreateItemFromTemplate

Set oMail = Application.CreateItemFromTemplate("c:\that\to\template.oft")
 
To make this clear. I am trying use the combo box so it shows all the macros that I have created and I can just pick the macro I want to run.

So what is the code that I should use so it goes to each macro as part of the combo box?
 
To run macros, you'll use Call macro_name or just macro_name in the Case line. If the macros are identical except for the template name, something like what i have on the website would be better.
Case 0
macro_name1
Case 1
macro_name2
 
Thank you very much.

Can you possibly just post the full code that I copy and past and wherever you put the word macro_name1 or macro_name2 etc., I will change it to the macro name of each macro.

I truly appreciate your help over the last couple of months as it has been wonderful and has helped me so so much!!
 
try something like this

Public Sub ChooseTemplate()

Dim oMail As Outlook.MailItem

Dim oContact As Outlook.ContactItem

Dim strTemplate As String
UserForm1.Show
Select Case lstNum
Case -1
macro_1
Case 0
macro_2
Case 1
macro_3
Case 2
macro_4
Case 3
macro_5
Case 4
macro_6
End Select

End Sub
 
thanks much...i will try it......

the first line of the first macro says: Public Sub From_Lou_Stoler()

So what is the macro name please? is it From_Lou_Stoler() or From Lou_Stoler
 
and see below as to Case -1 and tell me please the name of the macro and do I add the _1 at the end of it?:

Select Case lstNum
Case -1
From_Lou_Stoler_1
Case 0
macro_2
Case 1
macro_3
Case 2
macro_4
Case 3
macro_5
Case 4
macro_6
End Select
 
macro name would be From Lou_Stoler

- - - Updated - - -

if the macro name is

public sub From_Lou_Stoler_1()

then you'd use From_Lou_Stoler_1
 
It is public sub....so I did the following to try the first one and when I save it and then run it, the combo box shows up, I click on the side, and it opens up a the downlist, but nothing shows up in the downlist

Public Sub ChooseTemplate()

Dim oMail As Outlook.MailItem
Dim oContact As Outlook.ContactItem

Dim strTemplate As String
UserForm1.Show

Select Case lstNum
Case -1
From Lou_Stoler_1
Case 0
macro_2
Case 1
macro_3
Case 2
macro_4
Case 3
macro_5
Case 4
macro_6
End Select

End Sub

Private Sub CommandButton1_Click()

End Sub

Private Sub UserForm_Click()

End Sub

And the macro that works when when I use it in the ways you showed me.....the macro is as follows:

Public Sub From_Lou_Stoler()

Set oContact = GetCurrentItem()

Dim objMsg As MailItem

' Blank message

' Set objMsg = Application.CreateItem(olMailItem)

' Use a template

Set objMsg = Application.CreateItemFromTemplate("C:\Users\Stoler Law\AppData\Roaming\Microsoft\Templates\E-mail From Lou Stoler.oft")
objMsg.To = oContact.Email1Address
'displays the message form so you can enter more text
objMsg.Display
'use this to send to outbox
'objMsg.Send
Set objMsg = Nothing

End Sub

Function GetCurrentItem2() As Object
Dim objApp As Outlook.Application

Set objApp = Application
On Error Resume Next
Select Case TypeName(objApp.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
End Select

Set objApp = Nothing

End Function
 
Did you declare

Public lstNo As Long in the macro with the chooseForm macro?

it needs to match the variable in the command_click macro in the userform -
lstNo = cbList.ListIndex
 
thank for the details....but as i said before....i am not the technical person....so I don't understand what means declare.....and how something matches.....can you walk me thur the process as I showed you the code you gave me....and the macro that it refers to....also, the macro name did not include the _1, so that is not in the code...

which means....i don't undertand what to do next....as i don't know the concepts you mentioned
 
This is what the code should look like in the editor - the first line declares lstNo as a number (long). Then the macro follows and each Case calls a different macro. In my quickie example, i open a new message form and popup a msgbox.

macro.png
 
so is this what I should copy and past and just fill in the macro names from the top of each macro?
 
Yeah, pretty much. Your VBA will be something like this, since you are calling the template from the other macros.

Code:
Public lstNo As Long
Public Sub NewMessageUsingTemplate()
Dim oMail As Outlook.MailItem
UserForm1.Show
Select Case lstNo
Case -1 
 
macro1
Case 0 
 
macro2
Case 1 
 
macro3
End Select
End Sub
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
R List folders in a combo box + select folder + move emails from inbox to that folder + reply to that email Outlook VBA and Custom Forms 1
G Using Data From Combo Box in Appointment Body Outlook VBA and Custom Forms 6
P Custom Outlook form_Validations in combo box Outlook VBA and Custom Forms 0
S Outlook form - Combo box for deciding who to send form to Using Outlook 1
M details with the combo box Exchange Server Administration 3
Q Follow up: Make a combo box dependant on another Outlook VBA and Custom Forms 6
Q Make a combo box dependant on another Outlook VBA and Custom Forms 5
Q Load a recipient based on a value in a combo box Outlook VBA and Custom Forms 7
F Outlook 2010 - outlook userform and combo boxes Using Outlook 9
M Need help with combo boxes in messages! Using Outlook 10
M Outlook 2007 / Vista / Windows XP best combo needed BCM (Business Contact Manager) 2
P turn off the default "all day" check box in new calendar items. How? Using Outlook 1
S New Email "From" box stopped working Using Outlook 0
T Outlook 365 Search Box reverting to old location Using Outlook 2
J How do you disable address search box when typing @ in body of email? Using Outlook 0
L Is there a way to completely disable the "archive" box? Using Outlook 1
M Reverting The Outlook Search Box Location (or other undesired additions) Using Outlook 1
P outlook 2008 search box criteria couldn't be saved Using Outlook 2
Terry Sullivan E-Mails Sent Using a Group Box Result in 70 Kickbacks Using Outlook 4
N Private check box in table view Using Outlook 0
Commodore Folders always closed in move/copy items dialog box Using Outlook 3
P IMAP Folders Dialog Box Using Outlook 1
C Custom Outlook Form - Populate Information from Radio Button / Check Box Using Outlook 0
J Program Checkbox that will activate a text box in a Outlook fallible form. Outlook VBA and Custom Forms 1
CWM030 Call me old if you want. OL 2016 font size out of the box. Using Outlook 3
P Suppress dialog box on email check error? Using Outlook 5
E Don't want Inbox shown when login box is shown Using Outlook 1
stephen li VBA Outlook send mail automatically by specified outlook mail box Outlook VBA and Custom Forms 1
A GetSelectNamesDialog Pre-fill search box Outlook VBA and Custom Forms 12
P Outlook 2010 sending safe senders email to junk box Using Outlook 8
K Sharedmail box Outlook VBA and Custom Forms 4
Diane Poremsky Outlook Suggestion Box at Uservoice Using Outlook 0
D Emails do not appear in Sent box! Using Outlook 4
T OL2010 Password box keeps appearing. Using Outlook 6
A From box in custom outlook Form Outlook VBA and Custom Forms 0
Kristine RS box added in Favorites disappears Using Outlook 6
L An () has been inserted after the address in an address box; how do I remove them. Using Outlook 1
rohit I want to Populate Popup box while sending any email with attachment. Outlook VBA and Custom Forms 4
rohit I want to Populate Popup box while sending any email with attachment Using Outlook 1
moron save as & file location dialog box popup Outlook VBA and Custom Forms 2
Ross Garvey Dialogue box opens as I exit Using Outlook 2
P BCM 2013 Contacts Form Drop Down Box Bug BCM (Business Contact Manager) 1
C Outlook 2013 - Email Gets Sent - But Does Not Move From Outbox to Sent Box Using Outlook 4
G Enter Network Password box pops up every few seconds Using Outlook 2
V In Box Issues Using Outlook 1
S 2010 outlook today looks like an empty email box Using Outlook 4
S Custom yes/no message box. Using Outlook 0
L Auto-set followup/reminder popup box for ALL sent emails. Using Outlook 0
P VBA for Dialog Box when sending Email Using Outlook 8
V Clicking box to delete junk mail doesn't stay Using Outlook 2

Similar threads

Back
Top