【问题标题】:Appointment starts at the beginning of the calendar?约会从日历的开头开始?
【发布时间】:2012-11-26 12:20:31
【问题描述】:

我正在尝试从 VBA 宏生成约会并将其放入 Outlook 中的日历中。我的代码在下面...

Sub CommandButton1_Click()

Const olAppointmentItem As Long = 1
    Dim olapp As Object
    Dim OLNS As Object
    Dim OLAppointment As Object


    On Error Resume Next
    Set olapp = GetObject(, "Outlook.Application")
    If olapp Is Nothing Then Set olapp = CreateObject("Outlook.Application")
    On Error GoTo 0

    If Not olapp Is Nothing Then

        Set OLNS = olapp.GetNamespace("MAPI")
        OLNS.Logon

        Set OLAppointment = olapp.CreateItem(olAppointmentItem)
        OLAppointment.Subject = "Request for Leave"
        OLAppointment.Start = TimeValue(TextBox7.Text)
        OLAppointment.End = TimeValue(TextBox10.Text)

        OLAppointment.Location = "Leave"
        OLAppointment.Body = "Request for Leave"
        OLAppointment.Save

         'Set OLAppointment = olapp.Move(olfolder)

        Set OLAppointment = Nothing
        Set OLNS = Nothing
        Set olapp = Nothing
    End If

End Sub

问题是约会的日期从“1899 年 12 月 30 日星期六”开始,并且只持续半小时,而我需要它持续两个日期之间的几天作为全天约会贯穿始终,(开始日期:TextBox7)(结束日期:TextBox10)。

另一个问题是我如何将此请求发送给某人?

约会详情来自 Excel 用户窗体的文本字段

谢谢

【问题讨论】:

    标签: vba excel excel-2010


    【解决方案1】:

    TimeValue 似乎不允许您包含日期,只包含一天中的时间。例如,如果您使用以下格式设置开始和结束时间,那么它确实有效。

    OLAppointment.Start = #11/26/2012 1:00:00 PM#
    OLAppointment.End = #11/26/2012 2:00:00 PM#
    

    【讨论】:

      猜你喜欢
      • 2011-02-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多