I got an email from Dennis, a blind computer user (visually impaired as a bat, as he puts it). He uses a screen reading program that includes a scripting language. This language gives him access to the object models so he can get whatever information he needs.
What he needs to know is which day/time is selected when a user is looking at the calendar. That seems like it would be pretty easy, but you may be surprised. I went through every property and method of the ActiveExplorer object and could get there. Next I thought that I could create a new AppointmentItem and read where it defaulted the Start property. When I created a new AppointmentItem using
It defaulted to the current time, not the selected time. Drat.
Next, I discovered that selecting Actions > New Appointment would create an appointment with the proper Start default. The only problem was that I could find that commandbarcontrol. I looped through every commandbar and every control and simply could not locate it. I know it’s there.
Finally, I went with the old standby: SendKeys. This code produced a message box with the currently selected time. I’m sure it’s fraught with danger, but it’s the best I could do.
Dim dtSelected As Date
Dim i As Long
If Application.ActiveExplorer.CurrentFolder.DefaultItemType = olAppointmentItem Then
For i = 1 To 10000: DoEvents: Next i
dtSelected = Application.ActiveInspector.CurrentItem.Start
MsgBox Format(dtSelected, “mm/dd/yyyy hh:mm”)
By the way, this is still an Excel blog, but this particular piece of code goes in Outlook.