Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba 在打开事件中关闭outlook任务_Vba_Outlook - Fatal编程技术网

Vba 在打开事件中关闭outlook任务

Vba 在打开事件中关闭outlook任务,vba,outlook,Vba,Outlook,我想打开outlook任务并触发新日记账条目。 在此之后,我想关闭此任务。 我在objTask_Open事件中使用了objTask.Close,但这给了我以下错误:参数不是可选的。 打开任务后,是否可以在其自身的事件函数中关闭任务 致以最良好的祝愿 瓦莫尔 错误消息指示“参数非可选” 语法为expression.Close(SaveMode),其中参数SaveMode是必需的 从olDiscard或olPromptForSave或olSave中选择 Public WithEvents obj

我想打开outlook任务并触发新日记账条目。 在此之后,我想关闭此任务。 我在objTask_Open事件中使用了objTask.Close,但这给了我以下错误:参数不是可选的。 打开任务后,是否可以在其自身的事件函数中关闭任务

致以最良好的祝愿

瓦莫尔


错误消息指示“参数非可选”

语法为expression.Close(SaveMode),其中参数SaveMode是必需的

从olDiscard或olPromptForSave或olSave中选择

Public WithEvents objInspectors As Outlook.Inspectors
Public WithEvents objJournal As Outlook.JournalItem
Public WithEvents objTask As Outlook.TaskItem

Private Sub Application_Startup()
    Set objInspectors = Outlook.Inspectors
End Sub

Private Sub objInspectors_NewInspector(ByVal Inspector As Inspector)
    If TypeOf Inspector.CurrentItem Is TaskItem Then
       Set objTask = Inspector.CurrentItem
    End If
    If TypeOf Inspector.CurrentItem Is JournalItem Then
       Set objJournal = Inspector.CurrentItem
    End If
End Sub

Private Sub objTask_Open(Cancel As Boolean)
    'Create journal item
    Set objMyFolder = GetFolder("Archive Folders\Archive Folders")
    Set objJournal = objMyFolder.Items.Add(olJournalItem)

    'Fill journal with task-information
    With objJournal
        .StartTimer
        ' Retrieve the PST-file where the task is located.
        .Categories = Application.ActiveExplorer.CurrentFolder.Parent
        .Type = "Note"
        .Subject = objTask.Subject
        .Display
    End With
    objTask.Close
End Sub