Outlook VBA - How to access the time range selected in the calendar?

I am trying to write a VBA macro in Outlook that will allow me to display a user interface for entering information about Outlook meetings. I have work for existing appointments, but I would like to be able to create new appointments by clicking and dragging a user to select a time range, and then run the macro. (This works for the New Appointment built-in command in Outlook.) I would like to know how to programmatically get the selected time range so that I can use it when creating a new destination through a macro.

Does anyone know how to access this information from VBA?

+3
source share
2

:

: (VBA)?

+1

SelectedStartTime SelectedEndTime https://msdn.microsoft.com/en-us/library/office/ff869571.aspx

Public Sub GetNewAppt() 
    Dim exp As Explorer: Set exp = Outlook.ActiveExplorer
    Dim mfCalFolder As MAPIFolder
    Set mfCalFolder = exp.CurrentFolder
    Dim vw As View: Set vw = exp.CurrentView
    If vw.ViewType = olCalendarView Then
        With vw
            Dim objAppt As AppointmentItem
            Set objAppt = mfCalFolder.Items.Add
            objAppt.Start = .SelectedStartTime
            objAppt.End = .SelectedEndTime
            objAppt.Display
        End With
    End If
End Sub

. 2007 .

0

Source: https://habr.com/ru/post/1705137/


All Articles