Page 1 of 16 1234567811 ... LastLast
Results 1 to 10 of 158

Thread: Combo Box

  1. #1
    LMS
    LMS is offline Senior Member Outlook 2007
    Exchange Server account
    Join Date
    Jan 2013
    Posts
    201

    Default Combo Box

    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.

  2. #2
    larry's Avatar
    larry is offline Senior Member Outlook 2010 64 bit
    Exchange Server account
    Join Date
    May 2010
    Location
    Danville, PA
    Posts
    433

    Default Re: Combo Box

    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
    Larry the IT Guy

  3. #3
    LMS
    LMS is offline Senior Member Outlook 2007
    Exchange Server account
    Join Date
    Jan 2013
    Posts
    201

    Default Re: Combo Box

    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

  4. #4
    Diane Poremsky's Avatar
    Diane Poremsky is offline Outlook MVP Outlook 2013 64 bit
    Exchange Server account
    Join Date
    Jun 2009
    Location
    Ohio
    Posts
    4,572

    Default Re: Combo Box

    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\tem plate\" & strTemplate & ".oft")
    oMail .Display
    End Sub
    Last edited by Diane Poremsky; 01-26-2013 at 07:04 PM.

  5. #5
    LMS
    LMS is offline Senior Member Outlook 2007
    Exchange Server account
    Join Date
    Jan 2013
    Posts
    201

    Default Re: Combo Box

    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?

  6. #6
    Diane Poremsky's Avatar
    Diane Poremsky is offline Outlook MVP Outlook 2013 64 bit
    Exchange Server account
    Join Date
    Jun 2009
    Location
    Ohio
    Posts
    4,572

    Default Re: Combo Box

    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\tem plate.oft")

  7. #7
    Diane Poremsky's Avatar
    Diane Poremsky is offline Outlook MVP Outlook 2013 64 bit
    Exchange Server account
    Join Date
    Jun 2009
    Location
    Ohio
    Posts
    4,572

    Default Re: Combo Box

    As an FYI, i'm working on an article using a useform and template - page is at VBA UserForm sample: Select from a list of templates - Slipstick Systems - this sample gets the email address and name from a contact.

  8. #8
    LMS
    LMS is offline Senior Member Outlook 2007
    Exchange Server account
    Join Date
    Jan 2013
    Posts
    201

    Default Re: Combo Box

    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?

  9. #9
    Diane Poremsky's Avatar
    Diane Poremsky is offline Outlook MVP Outlook 2013 64 bit
    Exchange Server account
    Join Date
    Jun 2009
    Location
    Ohio
    Posts
    4,572

    Default Re: 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

  10. #10
    LMS
    LMS is offline Senior Member Outlook 2007
    Exchange Server account
    Join Date
    Jan 2013
    Posts
    201

    Default Re: Combo Box

    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!!

Page 1 of 16 1234567811 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •