Combo Box

Status
Not open for further replies.
I used the same macro name for all three just to see what shows up....

So where do I test it? As under the VBA area and I hit run, the combo box shows up but nothing in the downlist......

Since these macros listed only work when I click on a contact, how should I open up the userform combo box in a contact or after identifying the contact, and see what happens?

Make sense?

Here is the code per what you gave me as I posted the macro you can see earlier so you see the name etc.

Public lstNo As Long
Public Sub NewMessageUsingTemplate()
Dim oMail As Outlook.MailItem
UserForm1.Show
Select Case lstNo
Case -1

From_Lou_Stoler
Case 0

From_Lou_Stoler
Case 1

From_Lou_Stoler
End Select
End Sub

Private Sub ComboBox1_Change()

End Sub
 
Did you also add this to the userform?

Private Sub UserForm_Initialize()
cbList.AddItem "Potential client"
cbList.AddItem "New client welcome letter"
cbList.AddItem "Work order approval"
cbList.AddItem "Existing client"
cbList.AddItem "Payment overdue"
cbList.AddItem "Invoice"

End Sub

Private Sub btnOK_Click()
lstNo = cbList.ListIndex
Unload Me

End Sub
 
I did not. What area or part of the code do I put it, and as to each cb.ist.AddItem , should the words inside " " be the macro names?

Thanks very much. Will be excited to get it done.

And also, how do we create the button to the contact form so it open up the userform?

Thanks again so very much!!!
 
BTW, That is probably a bad example - that is from a macro I did with different variable names.

Make sure the name of the sub that adds the items is called

Private Sub UserForm_Initialize()

The click macro will be the name of the button control, CommandButton1 by default.
 
As a favor, please add to or change the code below what needs to be added or changed and where to put it. As again, I am not the expert!! Thanks so much. I truly appreciate your support!!

Public lstNo As Long
Public Sub NewMessageUsingTemplate()
Dim oMail As Outlook.MailItem
UserForm1.Show
Select Case lstNo
Case -1

From_Lou_Stoler
Case 0

From_Lou_Stoler
Case 1

From_Lou_Stoler
End Select
End Sub

Private Sub ComboBox1_Change()

End Sub

Private Sub UserForm_Click()

End Sub
 
This is not used:
Private Sub UserForm_Click()
End Sub

This goes in the userform with the userform_initilize routine.

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

End Sub

This goes into a module - because everything is being done in the other macros, you only need this much.

Public lstNo As Long

Public Sub NewMessageUsingTemplate()
UserForm1.Show
Select Case lstNo
Case -1
From_Lou_Stoler 'macro name
Case 0
From_Lou_Stoler 'macro name
Case 1
From_Lou_Stoler 'macro name
End Select
End Sub

I uploaded a video to youtube - the first minute shows how to set macro security - you can start it about 1 min.

Outlook Userform and Combo boxes - YouTube
 
Thanks very much as usual. Please see below and tell if this is correct?

And also, I have other combo boxes so the new one will be ComboBox7......that's ok ...correct?

And again , answer the above and review below so I can get this done right away.

And thanks so much

So the code of the UserForm1 is just:

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

End Sub

And I create a new module which is just:

Public lstNo As Long

Public Sub NewMessageUsingTemplate()
UserForm1.Show
Select Case lstNo
Case -1
From_Lou_Stoler 'macro name
Case 0
From_Lou_Stoler 'macro name
Case 1
From_Lou_Stoler 'macro name
End Select
End Sub
 
No, the code in the userform is not just the commandclick. you need to initialize it and set the list in the dropdown -

Private Sub UserForm_Initialize()

With Combox7
.AddItem "Potential client"
.AddItem "New client welcome letter"
.AddItem "Work order approval"
.AddItem "Existing client"
.AddItem "Payment overdue"
.AddItem "Invoice"

End With

End Sub

If you are using multiple comboxes, you need to make sure the code points to the right one - so in #7, it will be

Private Sub CommandButton1_Click()
lstNo = ComboBox7.ListIndex
Unload Me
End Sub
 
So this is the code I created and just have two .AddItem and i put in the name of each of the two macros....is that correct?

Private Sub UserForm_Initialize()

With Combox7
.AddItem "From_Lou_Stoler"
.AddItem "From_Lou_Stoler_and_Vcard"
End With
End Sub

Private Sub CommandButton1_Click()
lstNo = ComboBox7.ListIndex
Unload Me
End Sub

And this is the Module....is this correct?

Public lstNo As Long

Public Sub NewMessageUsingTemplate()

UserForm1.Show
Select Case lstNo
Case -1
From_Lou_Stoler 'macro name
Case 0
From_Lou_Stoler_and_Vcard 'macro name

End Select
End Sub
 
And the commandbutton as the new one is commandbutton4....and I changed that
 
Yes, that should work.
 
Did you review the codes I showed you? and those should work?

And how do I create the click to the userform in the contact tempate

I add a combo box and a command button and they are numbers i gave you, but nothing shows up on a list ..

As to each one it askes to assign it to a field? How do I do that, or just create shortcut to the userform?

Hopefully there is an easy way to do it....

Thanks so much for your continuing help!!!
 
you have an easily missed typo in Combox7, but with that fixed, it works here.

I used this code in the module. if the macros are in other modules they need to be public - private can only be called from the same module. to keep the index in the correct order, you need 0 and 1, plus -1.

When i run it, a msgbox pops up with one of the macro names.

Public lstNo As Long

Public Sub NewMessageUsingTemplate()

UserForm1.Show
Select Case lstNo
Case -1
From_Lou_Stoler 'macro name
Case 0
From_Lou_Stoler 'macro name
Case 1
From_Lou_Stoler_and_Vcard 'macro name

End Select
End Sub

Private Sub From_Lou_Stoler()

MsgBox "From_Lou_Stoler"

End Sub

Private Sub From_Lou_Stoler_and_Vcard()

MsgBox "From_Lou_Stoler_and_Vcard"

End Sub

Video of this in action 01.28.2013-12.08.24 - dicot's library
 
How do I run the userform thru a contact to see if it works: and see below:

This is the userform1:



Private Sub UserForm_Initialize()

With Combox7
.AddItem "From_Lou_Stoler"
.AddItem "From_Lou_Stoler_and_Vcard"
End With
End Sub

Private Sub CommandButton4_Click()
lstNo = ComboBox7.ListIndex
Unload Me
End Sub

This is the Module



Public lstNo As Long

Public Sub NewMessageUsingTemplate()

UserForm1.Show
Select Case lstNo
Case -1
From_Lou_Stoler 'macro name
Case 0
From_Lou_Stoler 'macro name
Case 1
From_Lou_Stoler_and_Vcard 'macro name

End Select
End Sub

Private Sub From_Lou_Stoler()

MsgBox "From_Lou_Stoler"

End Sub

Private Sub From_Lou_Stoler_and_Vcard()

MsgBox "From_Lou_Stoler_and_Vcard"

End Sub
 
To use it with select contacts, you need to add and if then statement:

'whatever

in this sample, it would be

Public lstNo As Long

' This will work with macros in a different module.

' Normally this is inside the sub as Dim oContact As Outlook.ContactItem

' and only works with the it is in.

Public oContact As Outlook.ContactItem

Public Sub NewMessageUsingTemplate()

If TypeName(ActiveExplorer.Selection.Item(1)) = "ContactItem" Then
Set oContact = ActiveExplorer.Selection.Item(1)

UserForm1.Show
Select Case lstNo
Case -1
From_Lou_Stoler 'macro name
Case 0
From_Lou_Stoler 'macro name
Case 1
From_Lou_Stoler_and_Vcard 'macro name
End Select

End if

Set oContact = Nothing
End Sub
 
I don't understand again.....

can you simply take my codes I gave you, and changes each one from the beginning to the end, so I can copy and paste them and see what happens
 
Here is the full summary of everything so hopefully you can show what to fix, and where.

I have the special macros that refer to an email template and when I click on a contact or open it, and run the macro, it automatically creates the e-mail from the template described in the macro, and automatically adds the e-mail address of the contact to the To bar of the e-mail.

In order to create a dropdown list of the macro's inside the contact template form, I did the following:

Under Project1 of the Visual Basic Editor, I created a new UserForm1 where I added a CommandButton4 and the Caption is "E-mails From Lou" and I added a ComboBox7 and the code of the ComboBox7 is:

Private Sub ComboBox1_Change()

End Sub

Private Sub UserForm_Initialize()

With Combox7

.AddItem "From_Lou_Stoler"

.AddItem "From_Lou_Stoler_and_Vcard"

End With

End Sub

Private Sub CommandButton4_Click()

lstNo = ComboBox7.ListIndex

Unload Me

End Sub

I added a new Module7 and the code is:

Public lstNo As Long

Public Sub NewMessageUsingTemplate()

UserForm1.Show

Select Case lstNo

Case -1

From_Lou_Stoler 'macro name

Case 0

From_Lou_Stoler 'macro name

Case 1

From_Lou_Stoler_and_Vcard 'macro name

End Select

End Sub

Private Sub From_Lou_Stoler()

MsgBox "From_Lou_Stoler"

End Sub

Private Sub From_Lou_Stoler_and_Vcard()

MsgBox "From_Lou_Stoler_and_Vcard"

End Sub

So the question is how to show the combo box list of macros per the codes of the UserForm1 and Module7?

I opened up the contact template, opened up the VBA, and copied and pasted to the contact template the commandbutton4 and the combobox7, and published the form so it shows up in all contacts, but no drop lists re the macro's show up under the combobox7. And as to the combobox7 in the contact, I created a new text field as it requires to have field.

Is there a way to finally fix this so I can see the dropdown list of the macros in the combobox?
 
Private Sub ComboBox1_Change()

End Sub

Private Sub UserForm_Initialize()

With Combox7
.AddItem "From_Lou_Stoler"
.AddItem "From_Lou_Stoler_and_Vcard"
End With
End Sub

Private Sub CommandButton4_Click()
lstNo = ComboBox7.ListIndex
Unload Me
End Sub

You have a typo/misspelling that needs fixed. It should work after that.
 
Can you show m what the type/misspelling words etc are.....i don't know what needs to be fixed.....thank you so much.....I am confused about the words..
 
And again, as a reminder, I am not the expert and just rely on what you have showed me to type in the whole time. So if you can copy what I posted of both codes, change them as needed, and post them back, I will copy and past to my computer, as I don't know what to fix.

And again, as well, I so appreciate your support. It's been the best forum I have ever used!!!
 
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