So I am an intern with very little VB experience, but my employer has tasked me with *attempting* to find or create a macro to intercept the reply all action to prompt a dialog box with options for "Yes" and "No". I found a few scripts that are similar to what we need the majority did not work at all, though the one posted at http://www.outlookcode.com/codedetail.aspx?id=1299 prompted the dialog box. It did so on both reply and reply all. If you choose the "no" option in that script it brings you to the message replying to the sender (Which I along with a few on my team like) BUT management wants it to basically do nothing if you say no. The script that I have now is an edited version of the script posted in the link above. Could anyone steer me in the right direction with this? Or link me to a script that is known to work?
Thanks.
Dim WithEvents colInsp As Outlook.Inspectors
Dim WithEvents msg As Outlook.mailItem
Dim replyAll As Boolean
Dim oLook As Outlook.Application
Private Sub Application_Startup()
Set colInsp = Application.Inspectors
End Sub
Private Sub colInsp_NewInspector(ByVal Inspector As Inspector)
Dim mymsg As String
Dim myResult As Integer
Dim count As Integer
Dim i As Integer
On Error Resume Next
If TypeOf Inspector.CurrentItem Is Outlook.mailItem Then
Set msg = Inspector.CurrentItem
' check if new item
If msg.Size = 0 Then
' check if replyall
If msg.Recipients.count > 1 Then
mymsg = "Do you really want to reply to all original recipients?"
myResult = MsgBox(mymsg, vbYesNo, "Flame Protector")
If myResult = vbNo Then
' remove all recipients except the first one
replyAll = False
'count = msg.Recipients.count
'For i = count To 2 Step -1
' msg.Recipients.Remove i
'Next
End If
End If
End If
Set msg = Nothing
End If
End Sub
Private Sub msg_Open(Cancel As Boolean)
If replyAll = False Then
Cancel = True
End If
End Sub
Private Sub msg_ReplyAll(ByVal Response As Object, Cancel As Boolean)
If replyAll = False Then
Cancel = True
End If
End Sub
Thanks.
Dim WithEvents colInsp As Outlook.Inspectors
Dim WithEvents msg As Outlook.mailItem
Dim replyAll As Boolean
Dim oLook As Outlook.Application
Private Sub Application_Startup()
Set colInsp = Application.Inspectors
End Sub
Private Sub colInsp_NewInspector(ByVal Inspector As Inspector)
Dim mymsg As String
Dim myResult As Integer
Dim count As Integer
Dim i As Integer
On Error Resume Next
If TypeOf Inspector.CurrentItem Is Outlook.mailItem Then
Set msg = Inspector.CurrentItem
' check if new item
If msg.Size = 0 Then
' check if replyall
If msg.Recipients.count > 1 Then
mymsg = "Do you really want to reply to all original recipients?"
myResult = MsgBox(mymsg, vbYesNo, "Flame Protector")
If myResult = vbNo Then
' remove all recipients except the first one
replyAll = False
'count = msg.Recipients.count
'For i = count To 2 Step -1
' msg.Recipients.Remove i
'Next
End If
End If
End If
Set msg = Nothing
End If
End Sub
Private Sub msg_Open(Cancel As Boolean)
If replyAll = False Then
Cancel = True
End If
End Sub
Private Sub msg_ReplyAll(ByVal Response As Object, Cancel As Boolean)
If replyAll = False Then
Cancel = True
End If
End Sub