Reply to all but sender macro

H

holla

I am not very familiar with outlook macros, I imagine there is a way t
make a reply to all but sender button as a macro in outlook. Doe
anyone out there know how to make a macro that would do this?

Basically the macro would do the same thing as reply to all, but woul
leave out the sender. I think we can all see the use for this
 
E

Eric Legault [MVP - Outlook]

Map this macro to a custom button on your toolbar for e-mail messages, then
click it while the message is open:

Sub ReplyToAllButSender()
On Error GoTo ReplyToAllButSender_Error

Dim objMsg As Outlook.MailItem, objReply As Outlook.MailItem
Dim objRecips As Outlook.Recipients, objRecip As Outlook.Recipient
Dim intX As Integer

If ActiveInspector Is Nothing Then Exit Sub
If ActiveInspector.CurrentItem.Class <> olMail Then Exit Sub

Set objMsg = ActiveInspector.CurrentItem
Set objReply = objMsg.ReplyAll
Set objRecips = objReply.Recipients

For intX = objRecips.Count To 1 Step -1
Set objRecip = objRecips.Item(intX)
If objRecip.Name = objMsg.SenderName Then
objRecip.Delete
End If
Next

objReply.Display
Set objMsg = Nothing
Set objReply = Nothing
Set objRecip = Nothing
Set objRecips = Nothing

On Error GoTo 0
Exit Sub

ReplyToAllButSender_Error:

MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
ReplyToAllButSender"
Resume Next
End Sub
 
H

holla

Thanks, that worked great. Just one more request, is there any way t
have it work when just viewing the message in the preview pane? If no
it's no big deal
 
E

Eric Legault [MVP - Outlook]

Absolutely - just use these two lines instead of the ActiveInspector ones:

If ActiveExplorer.Selection.Count <> 1 Then Exit Sub
If ActiveExplorer.Selection.Item(1).Class <> olMail Then Exit Sub
 
H

holla

I am getting errors when I put in that code. I keep getting repeate
errors of:

Error 91 (Object variable or with variable not set)

I thought it might be because there was another activeinspector on th
next line, so I replaced tht with active explorer and it gives me mor
errors, first it says:

Error 438 (Object doesnt support this property or method)

then it repeats the error 91's until I end task the program.


On another note, a lot of times when I uinlock my computer(XP Pro) th
visual basic editor opens up even though it was closed when I locke
the computer. Any idea why that is happening?

Thanks for all your help
 
E

Eric Legault [MVP - Outlook]

Did you completely remove both lines that were using ActiveInspector, and
replace them with the two ActiveExplorer lines I provided?

You'll also have to change this line of code:

Set objMsg = ActiveInspector.CurrentItem

To

Set objMsg = ActiveExplorer.Selection.Item(1)
 
E

Eric Legault [MVP - Outlook]

Oh yeah - that "ghost editor" phenomenon you mention has been happening to
me for years now, on all kinds of different computers. I've had it appear
when using Windows Media Player too. I've yet to see a fix/cause.
 
Top