vba - 如何格式化“.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
解决方案
您的表单可能会显示类似于日期和时间的文本值。使用 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
推荐阅读
- node.js - 错误消息:“不支持的投影选项:匹配:”
- mysql - 从 3 个表的查询中未返回任何记录
- python - 获取订阅的服务列表而不是资源
- java - Integer 和 Double 之间的 Nashorn 类型转换混淆
- postgresql - 在 kong pg_host 中设置多个 Postgresql 集群 IP
- java - org.jooq.exception.SQLDialectNotSupportedException:方言默认不支持类型类 java.net.Inet6Address
- python - 我想打印从 1 到 n 的数字,但运行此代码后,出现错误“core dumped”
- firebase - 如何在不使用 axios 或 fetch 的情况下从 https 函数 A 调用 firebase https 函数 B?
- sdk - 可以使用 Deep Security API(通过新的 DSaaS SDK)向计算机发送“升级代理”指令吗?
- reactjs - Webpack 'html-webpack-plugin' 在每次构建后添加额外的脚本