我有一些同事从共享的收件箱中删除了一些文件夹,让我发疯。
我让他们更加小心,但他们只是不给出^%& *。所以我得到了一个vba来阻止所有用户阻止他们从该共享邮箱中删除任何内容,但代码不起作用。
欢迎任何帮助。
Public WithEvents objCritFolder_EIE_E3Imp As Outlook.MAPIFolder
Public WithEvents objCritFolder_EIE_E3Man As Outlook.MAPIFolder
Private Sub application_Startup()
Dim ns As Namespace
Dim objRootFolder As Outlook.MAPIFolder
Set ns = Application.GetNamespace("MAPI")
Set objRootFolder = ns.Folders("MailBox - FOR ALL").Folders("Teams")
Set objCritFolder_EIE_E3Imp = objRootFolder.Folders("TODAY")
Set objCritFolder_EIE_E3Man = objRootFolder.Folders("TODAY + 1")
Set objRootFolder = Nothing
End Sub
Private Sub objCritFolder_EIE_E3Imp_BeforeFolderMove(ByVal MoveTo As MAPIFolder, cancel As Boolean)
Dim strMsg As String
cancel = True
strMsg = "You can't move the TODAY folder."
MsgBox strMsg, vbCritical, "Folder Move Not Allowed"
End Sub
Private Sub objCritFolder_EIE_E3Man_BeforeFolderMove(ByVal MoveTo As MAPIFolder, cancel As Boolean)
Dim strMsg As String
cancel = True
strMsg = "You can't move the TODAY + 1 folder."
MsgBox strMsg, vbCritical, "Folder Move Not Allowed"
End Sub
问题在于:
Public WithEvents objCritFolder_EIE_E3Imp As Outlook.MAPIFolder
Public WithEvents objCritFolder_EIE_E3Man As Outlook.MAPIFolder
它告诉我:“对象不会自动生成事件”
答案 0 :(得分:1)
我设法重新创建错误。通过从MAPIFolder中删除MAPI来修复它。
Public WithEvents objCritFolder_EIE_E3Imp As Outlook.Folder