VBA method to know Time Period selected from Calendar Day view

D

devlei

Does anyone know the VBA method to know what Time Period (say 08:00 am
to 10:00am) the user has selected on the 1 Day view from Calendar?
 
M

Michael Bauer

Hi,

there is no direct way.

Maybe possible, at least an interesting job, would be using some Win32
APIs. First you´need the Calendar´s window handle. With this you could
get its position and size. In this rectangle you can search pixel by
pixel for the color of selected rows. That´s the easy part of the job.

In addition you´d need an algorithm for getting the time. You could
store snaphots of each time, I mean e.g. the picture of 06:00, 07:00,
etc. But maybe there are better methods for recognizing pictures.

If you have e.g. the top position for a selected row then you could
"walk" left to the times and compare the pixels found there with your
stored snaphots.

Alternatively, of course, you could think about a re-design of your
solution. For humans it´s very easy to give you the needed data :)
 
D

devlei

It is strange that there is no direct way, considering the fact that
Outlook itself does this very thing every time you select "New..
Appointment". It uses the Date/Time selected on your Day View and
automatically fills in the Start and End fields on your new item.
 
Top