Combo Box

Status
Not open for further replies.
In the VBA editor, place the cursor in the line, right click > Toggle > Breakpoint. The macro will stop when it gets to that point.
 
I did it and here is what I learned and perhaps you now have an idea...

I created the breakpoint for the first line......

When I open the contact directly from the folder and click on macro to open the combobox from the macro and relate userform, the VBA Editor shows up immediately, the first line is yellow....then I keep clicking on F8 and it yellows different lines one after another, and then goes to the userform related to the module, and it does the same...and then it eventially will open up the combobox......

When I open the contact from the shortcut, it and click on macro to open the combobox from the macro and relate userform, the VBA Editor shows up immediately, the first line is yellow....then I keep clicking on F8 and it yellows different lines one after another, but will not go to the userform relate and will not open up the combobox....

So do you have any thoughts to fix it now?
 
That goes back to my friend telling me there were problems running code when items are opened using shortcuts and why I suggested changing Private to Public. The macro has no problems with everything in it's code but it can't "see" outside of the current module.
 
thanks very much as usual...as it is not my expertise!

you wrote the following to change to public before and I did it, but it did not fix it...any other thoughts?

Private Sub UserForm_Initialize()

and

Private Sub CommandButton5_Click()
 
I'm out of ideas. Sorry.
 
I appreciate your time as usual and if anything else hits your head, feel free to let me know, and if something else comes up, I will let you know as well.
 
One more area for you to see and let me know if you have a thought. You can can see earlier in this thread, the userform and related module codes, an there what happen when I run thru the breakpoint:

When I open the contact from the folder, and there is the breakpoint as I created it, the first line shows up as yellow, and then when I keep clicking on F8, the following lines show up yellow in the following order of lines going down:

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

Set oContact = GetCurrentItem()

Function GetCurrentItem() As Object

Set objApp = Application

On Error Resume Next

Select Case TypeName(objApp.ActiveWindow)

Case "Explorer"

Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)

End Select

Set objApp = Nothing

End Function

And then goes up to the following line in yellow:

UserForm10.Show

And then it goes to the Userform10, and yellows the lines going down:

Public Sub UserForm_Initialize()

With ComboBox16

.AddItem "Marketing Intro E-mail to GHP Contacts"

.AddItem "Follow-Up From Meeting at GHP Event"

End With

End Sub

And then it opens up the Combobox with the related CommandButton

And when I open the contact from the shortcut, from the module line, it does not got to each line as I mentioned above, it yellows the first line and then goes in the following order:

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

End If

Set oMail = Nothing

End Sub

And then it opens up the Userform10 in the Visual Basic Editor and not the Combobox and related CommandButton.

So is there a way to fix this so that when you open the contact from the shortcut, it goes thru the same process of opening up the Combobox and related CommandButton?
 
Per the above, I got a comment from another forum stating:

"Your code says if the first selected item in your folder is a contact item then go on and do all the stuff that's within the If-Then block.

In other words, if that If-condition is not true, then you don't have a contact item selected."

If this is the case, any idea how to adjust the code so that if the first selected item is the shortcut to the contact, then the contact from the shortcut is the contact item to get things going?

Would be a great answer if you agree with what was said and have an idea!!!
 
You have a contact open - because it was opened from a shortcut it may not have true focus. You can comment out that line and the end if and see if it works. Or... between these two lines:

End With

End If

add

Else

msgbox "what is this?"

and see if it works. If it sees the item the contact was attached it, it will error because the fields the macro needs are not available.

The reason for adding that line is so the code doesn't error if you accidently run it when you have something else selected.
 
The reason for adding that line is so the code doesn't error if you accidently run it when you have something else selected.

The reason for adding the If line is so it doesn't error.... but it will work without that line. Add

on error resume next

above the if line so it ends cleanly if it errors.
 
Thank you for your time very much. I am not good at typing in certain areas as not clear to me. So here is the code of the module, and can you add the words in the right places (and show them a bold) and then I can the right words to the right place. When i deleted the first line, it did not solve the problem. thanks much!!!

Public lstNum10 As Long

Public Sub Marketing_GHP_Contacts()

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
UserForm10.Show

Select Case lstNum10
Case -1
strTemplate = ("C:\Users\Stoler Law\AppData\Roaming\Microsoft\Templates\E-mail From Lou Stoler and Vcard.oft")
Case 0
strTemplate = ("C:\Users\Stoler Law\AppData\Roaming\Microsoft\Templates\Marketing Initial E-mail to GHP Contacts.oft")
Case 1
strTemplate = ("C:\Users\Stoler Law\AppData\Roaming\Microsoft\Templates\E-mail From Lou Stoler - Follow-Up From Meeting at GHP Event.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
 
Delete or comment out (add a ' at the beginning of the line so it turns green) to the two bolded lines in the original code. Add the error handler so it's less annoying if you select the wrong type of item.

On Error Resume NextIf TypeName(ActiveExplorer.Selection.Item(1)) = "ContactItem" Then
Set oContact = GetCurrentItem()
Dim strTemplate As String
UserForm10.Show
Select Case lstNum10
Case -1
strTemplate = ("C:\Users\Stoler Law\AppData\Roaming\Microsoft\Templates\E-mail From Lou Stoler and Vcard.oft")
Case 0
strTemplate = ("C:\Users\Stoler Law\AppData\Roaming\Microsoft\Templates\Marketing Initial E-mail to GHP Contacts.oft")
Case 1
strTemplate = ("C:\Users\Stoler Law\AppData\Roaming\Microsoft\Templates\E-mail From Lou Stoler - Follow-Up From Meeting at GHP Event.oft")
End Select
Set oMail = Application.CreateItemFromTemplate(strTemplate)
With oMail
.To = oContact.Email1Address
.Display
End With

End If
 
So this is the only line to adjust this way??

On Error Resume NextIf TypeName(ActiveExplorer.Selection.Item(1)) = "ContactItem" Then

- - - Updated - - -

And I don't understand what you mean by

"Delete or comment out (add a ' at the beginning of the line so it turns green) to the two bolded lines in the original code."

What lines am I supposed to delete please?
 
That was screwed up when i bolded it - the lines merged . :( You need to delete or comment the End If too.

On Error Resume Next

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

' End If

Your code should look like this - (but with more code in between the userform and the end if)

03.01.2013-14.24.png
 
So is this what it should look like please?

On Error Resume Next
If TypeName(ActiveExplorer.Selection.Item(1)) = "ContactItem" Then
Set oContact = GetCurrentItem()
Dim strTemplate As String
UserForm10.Show
Select Case lstNum10
Case -1
strTemplate = ("C:\Users\Stoler Law\AppData\Roaming\Microsoft\Templates\E-mail From Lou Stoler and Vcard.oft")
Case 0
strTemplate = ("C:\Users\Stoler Law\AppData\Roaming\Microsoft\Templates\Marketing Initial E-mail to GHP Contacts.oft")
Case 1
strTemplate = ("C:\Users\Stoler Law\AppData\Roaming\Microsoft\Templates\E-mail From Lou Stoler - Follow-Up From Meeting at GHP Event.oft")
End Select
Set oMail = Application.CreateItemFromTemplate(strTemplate)
With oMail
.To = oContact.Email1Address
.Display
End With
 
I did the forgoing and an error showed up since I deleted End If......and then when I put in back and above it added the On Error Resume Next, it does not work from the contact opening thru the shortcut.

Any other thoughts?
 
You need to delete the if line.

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

and the

End If
 
YOU ARE STILL THE BEST!!!!!

I deleted them both and when I open up the contact from the shortcut under the calendar, the macro works perfectly!!!

Thanks so so much!!
 
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