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
SendKeys “^+A”
For i = 1 To 10000: DoEvents: Next i
dtSelected = Application.ActiveInspector.CurrentItem.Start
Application.ActiveInspector.Close olDiscard
MsgBox Format(dtSelected, “mm/dd/yyyy hh:mm”)
End If
End Sub
By the way, this is still an Excel blog, but this particular piece of code goes in Outlook.
Dick,
Perhaps this MSFT’s KB-article may be of interest:
OL: How to Use CommandBars in Outlook Solutions
http://support.microsoft.com/default.aspx?scid=KB;en-us;Q201095
It includes a sample to generate the ID’s in Excel ;)
Kind regards,
Dennis
Dennis: Did you read that? Wow! What was that “For I = 1 to 35000? part? I can’t iterate through the commandbars collections? That’s one crazy object model.
Sue Mosher (Outlook MVP) has a bit of code for doing similar with Commandbars:
Create custom appointment with users time selection
Dick,
Yes, I read it but decided to post it as an amusement to us all. Last time I checked my test-machine was still working with the iteration :)
Anyway, Rob point You to a more reliable and workable source.
Kind regards,
Dennis