如果主题包含字符串,如何显示msgbox
问题描述:
以下Outlook宏完美工作,但是,我希望此MsgBox
仅在主题为LIKE 'Fees Due%'
或主题为LIKE' Status Change%'
时才会显示。这可能吗?如果主题包含字符串,如何显示msgbox
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
If MsgBox("Do you want to continue sending the mail?", vbOKCancel) <> vbOK Then
Cancel = True
End If
End Sub
答
应该
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim Subject As String
Subject = Item.Subject
If Subject Like "*Fees Due*" Or Subject Like "*Status Change*" Then
If MsgBox("Do you want to continue sending the mail?", _
vbYesNo + vbQuestion + vbMsgBoxSetForeground, _
"Check Subject") = vbNo Then
Cancel = True
End If
End If
End Sub
答
是。使用Like
操作:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
If Item.Subject Like "Fees Due*" Or Item.Subject Like "Status Change*" Then
If MsgBox("Do you want to continue sending the mail?", vbOKCancel) <> vbOK Then
Cancel = True
End If
End If
End Sub
我加入外If
... End If
,没有别的变化。
+0
谢谢。是的,这确实有效。 – Tennis
完美!正是我在找什么。感谢您多花一点时间来帮助。这让我从很多头痛中解脱出来。 – Tennis