首页 > 解决方案 > 如何格式化“.start”的时间部分以写入我的 Outlook 约会?我想使用表单用户的输入,这是我的

问题描述

如何格式化.start写入 Outlook 约会的时间部分?

我想使用表单用户的输入,这是我的代码。

此代码在我的日历上创建约会,但将时间设置为,12:00AM而不是从表单中获取输入时间 (Scheduled_Review_Time)。

我在属性中尝试了长、中和短时间格式。

private Sub Command160_Click()

Dim olApp As Outlook.Application
Dim olApt As AppointmentItem


Set olApp = New Outlook.Application
Set olApt = olApp.CreateItem(olAppointmentItem)


With olApt
.Start = Me.Scheduled_Review_Date
.End = Me.Scheduled_Review_Date
.Subject = Me.Title_of_Product
.Location = Me.Review_Location
.Body = "Please Join us for A Meeting"
.Duration = Me.Duration
' .To = Me.
   .BusyStatus = olBusy
   .ReminderMinutesBeforeStart = 15
   .ReminderSet = True


    .Save
End With


Set olApt = Nothing
Set olApp = Nothing

End Sub

标签: vbams-accessoutlook

解决方案


您的表单可能会显示类似于日期和时间的文本值。使用 CDate 和 CTime 转换为真实的日期和时间值。

With olApt

    .Start = cdate(Me.Scheduled_Review_Date) + cdate(me.Scheduled_Review_Time)
    'add 30 minutes for an end time
    .End = cdate(Me.Scheduled_Review_Date) + cdate(me.Scheduled_Review_Time) + timeserial(0, 30, 0)
    .Subject = Me.Title_of_Product
    .Location = Me.Review_Location
    .Body = "Please Join us for A Meeting"
    .Duration = Me.Duration
    ' .To = Me.
       .BusyStatus = olBusy
       .ReminderMinutesBeforeStart = 15
       .ReminderSet = True

    .Save
End With

推荐阅读