SelectionChange Event in Outlook Calender

G

Guest

Hi,
I am writing a Addin for Outlook in C#. In the calender in Outlook, I am
looking to retrieve the date a user clicks on (i.e. if the user selects any
date on the calender weather it has an appointment or not). I am able to
catch the event for when the user selects a date by using the SelectionChange
event but I am not able to know what date was selected ? Is it possible to
find the date selected and if so how ? Thanks.
 
S

Sue Mosher [MVP-Outlook]

Outlook fires no event when the user selects a date/time range. You can, however, use CommandBars methods to execute the New button from the toolbar/menu. That will create a new appointment using the user's selected date/time range. You can get the dates from that appointment and then discard it.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

When you click on a date on the calender (the yellow cells), the
"SelectChange" event seems to get fired (it also gets fired when you select
between different mail items in your mail box and possiblely or items in
different folders aswell). I will try opening a new appointment item, reading
the date and discarding it again but will this not cause an appointment item
to flash up on the screen each time the user clicks on a differnet date in
the calender ?
 
S

Sue Mosher [MVP-Outlook]

Yes, but you can close it as soon as you get the dates from it. Unless the user has a really slow system, they shouldn't notice.
 
G

Guest

Hi Sue,
Thanks for the help, I have managed to access the new button to open a
new appointment item but it keeps accessing the drop-down part of the button
that shows the other options in the new button and dosnt create a new
appointment item.

Office.CommandBar cb =
(Office.CommandBar)m_hExplorerObj.CommandBars["Standard"];

Office.CommandBarControl cbc = (Office.CommandBarControl)cb.Controls["&New"];

cbc.Execute();

How do I get it to create a new appointment item and does it return a handle
to that appointment so I can close it again ?
 
S

Sue Mosher [MVP-Outlook]

Don't use The name of the control. Use the ID, together with the FindControl method. The ID for a new appointment is 1106. See http://www.outlookcode.com/codedetail.aspx?id=616 for a VBA code sample.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


lg said:
Hi Sue,
Thanks for the help, I have managed to access the new button to open a
new appointment item but it keeps accessing the drop-down part of the button
that shows the other options in the new button and dosnt create a new
appointment item.

Office.CommandBar cb =
(Office.CommandBar)m_hExplorerObj.CommandBars["Standard"];

Office.CommandBarControl cbc = (Office.CommandBarControl)cb.Controls["&New"];

cbc.Execute();

How do I get it to create a new appointment item and does it return a handle
to that appointment so I can close it again ?
Sue Mosher said:
Yes, but you can close it as soon as you get the dates from it. Unless the user has a really slow system, they shouldn't notice.
 
G

Guest

Thats works perfectly, thanks Sue. The only thing though, the new appointment
ID 1106 did'nt work so I had to use ID 1992

Sue Mosher said:
Don't use The name of the control. Use the ID, together with the FindControl method. The ID for a new appointment is 1106. See http://www.outlookcode.com/codedetail.aspx?id=616 for a VBA code sample.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


lg said:
Hi Sue,
Thanks for the help, I have managed to access the new button to open a
new appointment item but it keeps accessing the drop-down part of the button
that shows the other options in the new button and dosnt create a new
appointment item.

Office.CommandBar cb =
(Office.CommandBar)m_hExplorerObj.CommandBars["Standard"];

Office.CommandBarControl cbc = (Office.CommandBarControl)cb.Controls["&New"];

cbc.Execute();

How do I get it to create a new appointment item and does it return a handle
to that appointment so I can close it again ?
Sue Mosher said:
Yes, but you can close it as soon as you get the dates from it. Unless the user has a really slow system, they shouldn't notice.

When you click on a date on the calender (the yellow cells), the
"SelectChange" event seems to get fired (it also gets fired when you select
between different mail items in your mail box and possiblely or items in
different folders aswell). I will try opening a new appointment item, reading
the date and discarding it again but will this not cause an appointment item
to flash up on the screen each time the user clicks on a differnet date in
the calender ?

:

Outlook fires no event when the user selects a date/time range. You can, however, use CommandBars methods to execute the New button from the toolbar/menu. That will create a new appointment using the user's selected date/time range. You can get the dates from that appointment and then discard it.

Hi,
I am writing a Addin for Outlook in C#. In the calender in Outlook, I am
looking to retrieve the date a user clicks on (i.e. if the user selects any
date on the calender weather it has an appointment or not). I am able to
catch the event for when the user selects a date by using the SelectionChange
event but I am not able to know what date was selected ? Is it possible to
find the date selected and if so how ? Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top