在Outlook中创建新约会时运行宏 [英] run a macro when creating new appointment in outlook

查看:170
本文介绍了在Outlook中创建新约会时运行宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Outlook vba的新手.

I'm new to outlook vba.

当我在Outlook 2016 32位版的m​​ycalendar中创建新约会时,我想运行一个宏

I'd like to run a macro when I create a new appointment in mycalendar in Outlook 2016 32bit

我尝试过

Private WithEvents appt As Outlook.AppointmentItem

Private Sub appt_Write(Cancel As Boolean)
MsgBox ("test ok")
End Sub

在ThisOutlookSession模块中,但是当我编辑并保存新约会时没有任何反应.

in the ThisOutlookSession module but nothing happens when I edit anda save a new appointment.

我该怎么办?

推荐答案

来自 outlook事件newMail(newItem)

Private WithEvents appt As AppointmentItem
Private WithEvents objinspectors As Outlook.Inspectors

Private Sub Application_Startup()
    Set objinspectors = Application.Inspectors
End Sub

Private Sub objinspectors_NewInspector(ByVal Inspector As Inspector)
    If TypeName(Inspector.currentItem) = "AppointmentItem" Then
        MsgBox "newinspector"
        Set appt = Inspector.currentItem    ' <----
    End If
End Sub

Private Sub appt_Write(Cancel As Boolean)
    MsgBox ("test ok")
End Sub

appt将是最近打开的约会项目

appt will be the most recently opened appointment item

这篇关于在Outlook中创建新约会时运行宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆