Combo Box

Status
Not open for further replies.
Lower case L - VBA doesn't like leading numbers. Yes, you can add a 2 to the end.
 
In userform2, I changed lstNum = ComboBox7.ListIndex to lstNum2 = ComboBox7.ListIndex

In the new Module, I changed Select Case lstNum to Select Case lstNum2

And the first Module that we created still shows the error I told you....and the second Module just created, only opens up the -1 template....

What to fix please?

Also, is there a place in the userform2 to identify the correct Module?

So two questions above

thanks so much!
 
Here is the update with the following userform2 code and the Module8 Code: userform1 works fine....and under userform 2 and Module8, the droplist does not show up

Private Sub ComboBox1_Change()

End Sub

Private Sub ComboBox8_Change()

End Sub

Private Sub UserForm2_Initialize()

With ComboBox8
.AddItem "Today-Meeting_Thank-You_Friend"
.AddItem "Recent-Meeting_Thank-You_Friend"
.AddItem "Recent-Meeting_Thank-You_Network_Contact"
.AddItem "Today_Meeting_Thank-You_Network_Contact"
End With
End Sub

Private Sub CommandButton5_Click()
lstNum2 = ComboBox8.ListIndex
Unload Me
End Sub

Private Sub UserForm_Click()

End Sub

Public lstNum2 As Long

Public Sub ChooseTemplate2()

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

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

Dim strTemplate As String
UserForm2.Show

Select Case lstNum2
Case -1
strTemplate = ("C:\Users\Stoler Law\AppData\Roaming\Microsoft\Templates\E-mail From Lou Stoler.oft")
Case 0
strTemplate = ("C:\Users\Stoler Law\AppData\Roaming\Microsoft\Templates\E-mail From Lou Stoler - Today Meeting Thank-You - Friend.oft")
Case 1
strTemplate = ("C:\Users\Stoler Law\AppData\Roaming\Microsoft\Templates\E-mail From Lou Stoler - Recent Meeting Thank-You - Friend.oft")
Case 2
strTemplate = ("C:\Users\Stoler Law\AppData\Roaming\Microsoft\Templates\E-mail From Lou Stoler - Recent Meeting Thank-You - Network Contact.oft")
Case 3
strTemplate = ("C:\Users\Stoler Law\AppData\Roaming\Microsoft\Templates\E-mail From Lou Stoler - Today Meeting Thank-You - Network Contact.oft")
End Select
Set oMail = Application.CreateItemFromTemplate(strTemplate)

With oMail
.To = oContact.Email1Address
.Display
End With
End If
Set oMail = Nothing

End Sub

Function GetCurrentItem() 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
 
hi...did you have a chance to look at the above?
 
Nah... I sometimes take weekends off. :)

When the combobox is not showing data, the problem is usually with the combobox code. Verify it is really combobox8

right click in the combobox in the editor and choose view code - it should add something like this to the code editor -

Private Sub ComboBox1_Change()

End Sub

If its not combobox8, you need to change the code to whatever it says.

You can also check in the properties dialog -

combo-property.png
 
the combobox8 code is:

Private Sub ComboBox1_Change()

End Sub

Private Sub ComboBox8_Change()

End Sub

Private Sub UserForm2_Initialize()

With ComboBox8
.AddItem "Today-Meeting_Thank-You_Friend"
.AddItem "Recent-Meeting_Thank-You_Friend"
.AddItem "Recent-Meeting_Thank-You_Network_Contact"
.AddItem "Today_Meeting_Thank-You_Network_Contact"
End With
End Sub

Private Sub CommandButton5_Click()
lstNum2 = ComboBox8.ListIndex
Unload Me
End Sub

Private Sub UserForm_Click()

End Sub

the private sub shows up twice...one with ComboBox1 and the other with ComboBox8.......

Do I change the private sub with ComboBox1 to ComboBox8 or just delete it?
 
the userform combobox7 code is:

Private Sub ComboBox1_Change()

End Sub

Private Sub ComboBox7_Change()

End Sub

Private Sub UserForm_Initialize()

With ComboBox7
.AddItem "From_Lou_Stoler"
.AddItem "From_Lou_Stoler_and_Vcard"
.AddItem "Good_Morning_Catch_Up"
.AddItem "Good_Afternoon_Catch_Up"
.AddItem "Good_Morning_Catch_Up_to_Client"
.AddItem "Good_Afternoon_Catch_Up_to_Client"
.AddItem "Today_Meeting_Thank_You_Friend"
.AddItem "Recent_Meeting_Thank_You_Friend"
End With
End Sub

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

and I have the one for combox8 the following:

Private Sub ComboBox1_Change()

End Sub

Private Sub ComboBox8_Change()

End Sub

Private Sub UserForm2_Initialize()

With ComboBox8
.AddItem "Today-Meeting_Thank-You_Friend"
.AddItem "Recent-Meeting_Thank-You_Friend"
.AddItem "Recent-Meeting_Thank-You_Network_Contact"
.AddItem "Today_Meeting_Thank-You_Network_Contact"
End With
End Sub

Private Sub CommandButton5_Click()
lstNum = ComboBox8.ListIndex
Unload Me
End Sub

Private Sub UserForm_Click()

End Sub

which automatically includes

Private Sub UserForm_Click()

End Sub

so please review the foregoing and let me know as it still want show the droplis in combobox8
 
Delete those empty subs - Outlook creates them automatically when you click on the form. If there is nothing between the Sub / End sub, it's just taking up space.
 
Well, that took 3 times longer to pick out the problem than it should have - it needs to be "Private Sub UserForm_Initialize()" - this doesn't get numbered to match the form name.
 
Sorry. Don't know what lines to delete. Please tell me as when i deleted the last two lines Private Sub UserForm_Click()

End Sub and saved the code, they still show up when i open the code.

- - - Updated - - -

Sorry. Don't know what lines to delete. Please tell me as when i deleted the last two lines Private Sub UserForm_Click()

End Sub and saved the code, they still show up when i open the code.
 
they'll get added back when you click on the form - if they come back don't worry about it, but remove any empty ones when you paste code from another userform to reduce confusion.
 
The list shows up now. Thank you.

Here are the next problems:

When I click on the commandbutton without identifying a case in the list, it goes to the Case0 not Case -1.

Secondly, when I click in the case in the list which is case1, case2 or case3, each one only uses case0.

Can we fix this areas please?
 
Is this line in this useform like this?
lstNum = ComboBox8.ListIndex

it needs to be lstnum2
 
You did it again. You are the best!!! It's working!!!

So if you can, just post a list of the things I change for each new userform and related combox......and then I will have the list of what to do each time.

'

This is perfect, as everyone in the past said there was not way to create a droplist inside the contact.....and now it is done!!

Thank you very very much!!
 
Technically, its not inside the contact. It's just a macro - and a pretty good way of bringing up templates.

Everything in bold needs updated in new macro

user form:
Private Sub UserForm_Initialize()
With ComboBox8

> AddItem "a"
.AddItem "b"
End With
End Sub
Private Sub CommandButton5_Click()

lstNum = ComboBox8.ListIndex
Unload Me
End Sub

macro:

Public lstNum As Long

Public Sub ChooseTemplate()

Dim oMail As Outlook.MailItem

Dim oContact As Outlook.ContactItem

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

Dim strTemplate As String
UserForm.Show
Select Case lstNum
Case -1
strTemplate = "default"
Case 0
strTemplate = "a"
Case 1
strTemplate = "b"
End Select

Set oMail = Application.CreateItemFromTemplate(strTemplate)

With oMail
.To = oContact.Email1Address
.Display

End With
End If

Set oMail = Nothing

End Sub
 
Thanks so so much!

It is now working perfectly and I created 4 different userforms and modules to them....and then added each macro to the Quick Access Tool Bar, and have the bullet points in the Contacts to open the droplists thru the macros!

Once again, I so appreciate your great and fast support!!
 
hi...believe it or not, I did it again....with userform6 and module 12......it is command button 9 and combobox12....I changes all of those areas re exactly what you showed me to do...and the debug comes in the module that "UserForm6.Show" is in yellow....

did I miss something? thanks very much as usual.
 
That usually means it can't find the userform to show. Triple check the name of the form. If the problem was with the button and box #, it wouldn't do anything or those drop downs would be empty.
 
When I click on it in the userform the words come up:



Userform6 = <Object variable or With block variable notset
So what should I do please?




- - - Updated - - -

also, before I put this together, I had created a first userform6 and deleted it and not exported it as i thought earlier I didn't need another one....and then I created the userform6 as a new useform after I deleted the earlier one.
 
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