检查Excel是否提供Outlook日历日期和时间

时间:2018-07-10 07:17:05

标签: excel excel-vba outlook

在通过用户表单设置约会之前,我如何让excel检查键入的日期和时间在Outlook中是否可用?理想情况下,如果时间不可用,我希望显示“ msgbox”。这是我当前的代码,可通过我的用户窗体将约会从excel设置为Outlook:

Sub outlook_call()


Dim cb As Object
Dim lastrow As Long, ws As Worksheet
Set ws = Sheets("appointments")
lastrow = ws.Cells(Rows.Count, 11).End(xlUp).Row + 1

'Outlook begin here////////////
' Create the Outlook session
    Set myOutlook = CreateObject("Outlook.Application")


    Do Until appvision.appname.Value = ""
        ' Create the AppointmentItem
        Set myApt = myOutlook.CreateItem(1)
        ' Set the appointment properties
        myApt.Subject = appvision.appname.Value
        myApt.Location = appvision.appname.Value
        myApt.Start = appvision.TextBox2.Value
        'myApt.Duration = appvision.ComboBox1.Value
         'If Busy Status is not specified, default to 2 (Busy)
        'If UserForm2.ComboBox3.Value = "" Then
         '  myApt.BusyStatus = 2
        'Else
           ' myApt.BusyStatus = UserForm2.ComboBox3.Value
       ' End If
        If appvision.TextBox9.Value > 0 Then
          myApt.ReminderSet = True
           myApt.ReminderMinutesBeforeStart = appvision.TextBox9.Value
        Else
            myApt.ReminderSet = False
        End If
        myApt.Body = appvision.TextBox4.Value
        myApt.Display
    Exit Do
    Loop
    End Sub

0 个答案:

没有答案