![]() |
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
|
|||
|
|||
![]()
Hello,
I am trying to get the selected date from the calendar month view. I already learned that the calendar view object itself does not provide any means to get that data, however, I found Sue Moshers solution on http://www.outlookcode.com/codedetail.aspx?id=616 Basically, it fetches the command for a new appointment, executes it (so the new appointment form would open), reads the start and end date from the form and closes it again. The problem here is that the execute command does not "work" - there is no new appointment form that opens. No error message, no exception, just nothing is happening. Several other readers had that problem, too, and the solution seemed to be that the command bars had to be reset. But I did not change any command bars here (no custom commands yet), so I can not reset them. Can anyone help me? Marc |
Ads |
#2
|
|||
|
|||
![]()
The command being executed is the New, Appointment command on the Standard
toolbar. Is that being displayed and are you displaying a calendar folder when you execute your code? What if you switch the command button and try using 1992 as the button ID to execute, does that work? That's the Actions, New Appointment button. -- 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 "Marc Weichhold" wrote in message ... Hello, I am trying to get the selected date from the calendar month view. I already learned that the calendar view object itself does not provide any means to get that data, however, I found Sue Moshers solution on http://www.outlookcode.com/codedetail.aspx?id=616 Basically, it fetches the command for a new appointment, executes it (so the new appointment form would open), reads the start and end date from the form and closes it again. The problem here is that the execute command does not "work" - there is no new appointment form that opens. No error message, no exception, just nothing is happening. Several other readers had that problem, too, and the solution seemed to be that the command bars had to be reset. But I did not change any command bars here (no custom commands yet), so I can not reset them. Can anyone help me? Marc |
#3
|
|||
|
|||
![]()
Hello Ken.
The command being executed is the New, Appointment command on the Standard toolbar. Is that being displayed and are you displaying a calendar folder when you execute your code? Yes, I am displaying the calendar month view when the code is executed and the command (New, Appointment) is displayed on the standard toolbar. What if you switch the command button and try using 1992 as the button ID to execute, does that work? That's the Actions, New Appointment button. I tried it and the behavior is the same as before. The execute command does not open the appointment form and I get no error or exception. The "funny" part is, for testing purposes I changed the caption of the command right before I call the execute method - and that works. The caption is changed, but the execute method is still without effect. Marc PS: Btw, if that is important, I am using Outlook 2007 with Exchange Server 2007 and a Visual Studio 2008 Developer Edition. The AddIn language is C#. |
#4
|
|||
|
|||
![]()
Hello,
one more information. I tried the code from Sue as a VBA macro - and it worked. Strange... Marc |
#5
|
|||
|
|||
![]()
Now I'm confused.
The code Sue had up is an Outlook VBA macro. What were you trying it as previously? If the code wasn't running inside the Outlook VBA project it would never work as written, the Application object referenced wouldn't be an Outlook.Application object. -- 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 "Marc Weichhold" wrote in message ... Hello, one more information. I tried the code from Sue as a VBA macro - and it worked. Strange... Marc |
#6
|
|||
|
|||
![]()
Hello Ken,
The code Sue had up is an Outlook VBA macro. What were you trying it as previously? If the code wasn't running inside the Outlook VBA project it would never work as written, the Application object referenced wouldn't be an Outlook.Application object. I used the code in a VSTO-AddIn written in C#. Of course, I made some changes so it would compile and run. It is not that hard, after all I GET the right button. I can read its properties, even change them. All that does not work - in the C#-AddIn - is the Execute-method. For C# the code changes to: // Application is of type Microsoft.Office.Interop.Outlook.Application Outlook.Explorer objExpl = Application.ActiveExplorer(); if(objExpl != null) { Outlook.Folder objFolder = (Outlook.Folder)objExpl.CurrentFolder; if(objFolder.DefaultItemType == Outlook.OlItemType.olAppointmentItem) { Office.CommandBarButton objCB = (Office.CommandBarButton)objExpl.CommandBars.FindC ontrol(Type.Missing, 1106, Type.Missing, Type.Missing); if(objCB != null) { objCB.Execute(); Outlook.AppointmentItem objAppt = (Outlook.AppointmentItem)Application.ActiveInspect or().CurrentItem; DateTime dtStart = objAppt.Start; DateTime dtEnd = objAppt.End; ((Outlook._AppointmentItem)objAppt).Close(Microsof t.Office.Interop.Outlook.OlInspectorClose.olDiscar d); } } } And as I said, if I place objCB.Caption = "BlahBlah"; before objCB.Execute(); then the caption of the button is changed. Marc |
#7
|
|||
|
|||
![]()
If you were to breakpoint on the line:
DateTime dtStart = objAppt.Start; does an Inspector ever get opened with the appointment? I just tried your code and it works here with no problems with Outlook 2007 and a VSTO addin written in C#. I fired the code from a button click in an Explorer window, the code ran from my Explorer wrapper class. About the only change I made was to just use the class level Explorer object in the wrapper and not use an Application object to get ActiveExplorer(). Other than that my code was a copy and paste of yours. So I'm not sure why it's not working for you. -- 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 "Marc Weichhold" wrote in message ... Hello Ken, The code Sue had up is an Outlook VBA macro. What were you trying it as previously? If the code wasn't running inside the Outlook VBA project it would never work as written, the Application object referenced wouldn't be an Outlook.Application object. I used the code in a VSTO-AddIn written in C#. Of course, I made some changes so it would compile and run. It is not that hard, after all I GET the right button. I can read its properties, even change them. All that does not work - in the C#-AddIn - is the Execute-method. For C# the code changes to: // Application is of type Microsoft.Office.Interop.Outlook.Application Outlook.Explorer objExpl = Application.ActiveExplorer(); if(objExpl != null) { Outlook.Folder objFolder = (Outlook.Folder)objExpl.CurrentFolder; if(objFolder.DefaultItemType == Outlook.OlItemType.olAppointmentItem) { Office.CommandBarButton objCB = (Office.CommandBarButton)objExpl.CommandBars.FindC ontrol(Type.Missing, 1106, Type.Missing, Type.Missing); if(objCB != null) { objCB.Execute(); Outlook.AppointmentItem objAppt = (Outlook.AppointmentItem)Application.ActiveInspect or().CurrentItem; DateTime dtStart = objAppt.Start; DateTime dtEnd = objAppt.End; ((Outlook._AppointmentItem)objAppt).Close(Microsof t.Office.Interop.Outlook.OlInspectorClose.olDiscar d); } } } And as I said, if I place objCB.Caption = "BlahBlah"; before objCB.Execute(); then the caption of the button is changed. Marc |
#8
|
|||
|
|||
![]()
Hello Ken,
If you were to breakpoint on the line: DateTime dtStart = objAppt.Start; does an Inspector ever get opened with the appointment? No, there is no Inspector opened at all. The code does throw an exception at the line Outlook.AppointmentItem objAppt = (Outlook.AppointmentItem)Application.ActiveInspect or().CurrentItem; because the method ActiveInspector() returns null. And that's why it would never reach a breakpoint at the line with dtStart. If I understood it right, the button's Execute-method is supposed to open a new Inspector object (which then does open the appointment form). But that never happens, so there is no ActiveInspector at all after the Execute command. The container Application.Inspectors is also empty at the point (Count = 0). I just tried your code and it works here with no problems with Outlook 2007 and a VSTO addin written in C#. I fired the code from a button click in an Explorer window, the code ran from my Explorer wrapper class. About the only change I made was to just use the class level Explorer object in the wrapper and not use an Application object to get ActiveExplorer(). Other than that my code was a copy and paste of yours. So I'm not sure why it's not working for you. Beats me, too. From your experience, would you really think that the Explorer object is the "problem"? I mean, after all I can manipulate the button object that I get from the Explorer's command bars... Marc PS: Happy Holidays. |
#9
|
|||
|
|||
![]()
I have no idea what the problem is since the same code worked perfectly
here. I tested it in Outlook 2007, with a VSTO addin written in C# with your code. That's about as close as I can get to whatever your setup is. Are you running any Outlook addins at all? I'd disable any that might be running just on the off chance that some other addin is messing up yours. But I wouldn't put money on that being the problem. Happy holidays to you too, and to everyone here. -- 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 "Marc Weichhold" wrote in message ... Hello Ken, If you were to breakpoint on the line: DateTime dtStart = objAppt.Start; does an Inspector ever get opened with the appointment? No, there is no Inspector opened at all. The code does throw an exception at the line Outlook.AppointmentItem objAppt = (Outlook.AppointmentItem)Application.ActiveInspect or().CurrentItem; because the method ActiveInspector() returns null. And that's why it would never reach a breakpoint at the line with dtStart. If I understood it right, the button's Execute-method is supposed to open a new Inspector object (which then does open the appointment form). But that never happens, so there is no ActiveInspector at all after the Execute command. The container Application.Inspectors is also empty at the point (Count = 0). I just tried your code and it works here with no problems with Outlook 2007 and a VSTO addin written in C#. I fired the code from a button click in an Explorer window, the code ran from my Explorer wrapper class. About the only change I made was to just use the class level Explorer object in the wrapper and not use an Application object to get ActiveExplorer(). Other than that my code was a copy and paste of yours. So I'm not sure why it's not working for you. Beats me, too. From your experience, would you really think that the Explorer object is the "problem"? I mean, after all I can manipulate the button object that I get from the Explorer's command bars... Marc PS: Happy Holidays. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Determine selected date in Outlook 2007? | AD | Outlook and VBA | 1 | January 31st 07 07:01 PM |
Personal Calendar Item copied to a selected public folder calendar | Wanda | Outlook and VBA | 1 | November 1st 06 07:57 PM |
end date entered occurred before the start date in a calendar | office problem | Outlook - Calandaring | 1 | August 28th 06 04:22 AM |
Outlook should allow appointments to recur by selected date | Alison the Assistant | Outlook - Calandaring | 1 | August 21st 06 11:35 PM |
Timespan selected in Calendar | Alexander Rozhin | Add-ins for Outlook | 1 | August 12th 06 12:54 AM |