![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
I have a mail folder called MyInfo when I click on a mail item inside that
folder I want to execute vba code to go and grab details from a SQL Server Database, My problem is I cant find an "OnClick" event when a mail item is mouse clicked Can any one help! |
#2
|
|||
|
|||
![]()
When you click on an item in a folder it changes the selection. You can use
the Explorer.SelectionChange() event for what you want. Instantiate an Explorer object declared WithEvents to handle the SelectionChange() event and instantiate that Explorer object as the ActiveExplorer. When that event fires you can get the Explorer.Selection collection, which can be iterated to handle all selected items. If there's only 1 selected item then Selection.Item(1) will get that item in the event handler. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "Mark" wrote in message ... I have a mail folder called MyInfo when I click on a mail item inside that folder I want to execute vba code to go and grab details from a SQL Server Database, My problem is I cant find an "OnClick" event when a mail item is mouse clicked Can any one help! |
#3
|
|||
|
|||
![]()
Im don't know how to perform the following:
"Instantiate an Explorer object declared WithEvents to handle the SelectionChange() event and instantiate that Explorer object as the ActiveExplorer." Do you have an example! __________________________________________________ _____________ "Ken Slovak - [MVP - Outlook]" wrote: When you click on an item in a folder it changes the selection. You can use the Explorer.SelectionChange() event for what you want. Instantiate an Explorer object declared WithEvents to handle the SelectionChange() event and instantiate that Explorer object as the ActiveExplorer. When that event fires you can get the Explorer.Selection collection, which can be iterated to handle all selected items. If there's only 1 selected item then Selection.Item(1) will get that item in the event handler. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "Mark" wrote in message ... I have a mail folder called MyInfo when I click on a mail item inside that folder I want to execute vba code to go and grab details from a SQL Server Database, My problem is I cant find an "OnClick" event when a mail item is mouse clicked Can any one help! |
#4
|
|||
|
|||
![]()
You can put the code in the ThisOutlookSession class and use something like
this: Dim WithEvents oExpl As Outlook.Explorer Private Sub Application_Startup() Set oExpl = Application.ActiveExplorer End Sub Private Sub oExpl_SelectionChange() Dim colSelection As Outlook.Selection Dim obj As Object Dim oMail As Outlook.MailItem Set colSelection = oExpl.Selection For Each obj In colSelection If obj.Class = olMail Then Set oMail = obj ' is a selected mail item do whatever with it End If Next End Sub -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "Mark" wrote in message ... Im don't know how to perform the following: "Instantiate an Explorer object declared WithEvents to handle the SelectionChange() event and instantiate that Explorer object as the ActiveExplorer." Do you have an example! |
#5
|
|||
|
|||
![]()
Thankyou Ken, Once again I appreciate your help
All is no working well "Ken Slovak - [MVP - Outlook]" wrote: You can put the code in the ThisOutlookSession class and use something like this: Dim WithEvents oExpl As Outlook.Explorer Private Sub Application_Startup() Set oExpl = Application.ActiveExplorer End Sub Private Sub oExpl_SelectionChange() Dim colSelection As Outlook.Selection Dim obj As Object Dim oMail As Outlook.MailItem Set colSelection = oExpl.Selection For Each obj In colSelection If obj.Class = olMail Then Set oMail = obj ' is a selected mail item do whatever with it End If Next End Sub -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "Mark" wrote in message ... Im don't know how to perform the following: "Instantiate an Explorer object declared WithEvents to handle the SelectionChange() event and instantiate that Explorer object as the ActiveExplorer." Do you have an example! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Remove Mail Item Event Doesn't Fire | Nenad | Add-ins for Outlook | 3 | November 8th 08 05:58 AM |
New Mail Item Event | Neetu | Add-ins for Outlook | 6 | April 4th 08 02:11 PM |
How to track the right click on the mail item??? | Laxman | Add-ins for Outlook | 0 | July 3rd 06 10:36 AM |
double click mail item | jpspringall | Outlook and VBA | 2 | May 31st 06 10:18 AM |
Trigger event on explorer right click (unselected item)? | james | Add-ins for Outlook | 5 | February 22nd 06 09:12 PM |