Status
Not open for further replies.

#### John Booze

New Member
Hi Diane, can you help me with VBA code to be used in Outlook 2013. This is what I would like to do:
1. I will select Reply To All and then run the code.
2. The code will add an attachment, insert certain text to the top of the body of the email reply, and insert my signature under the text.
Please me know if you can assist with this or point me to a source that can?
Thank you, John

#### Diane Poremsky

Senior Member
code sample here to do something when you hit the reply/reply all, or forward button - i believe it includes a code sample to add text while keeping the original body as is : VBA Sample: Do Something When Reply is Clicked

signature should be added automatically, if not, i have code at slipstick that does that too.

#### John Booze

New Member
Hi Diane,
I found a script that might help me. But I'm am having problems testing it. Here is what's happening and the questions I have:
1. When I try to run the script I get an empty macro window with nothing in it (see attached)?
2. From what I have read all macro's for Outlook must be contained in ThisOutlookSession. How can you create and call more than one macro if they are all in the same place in VBA (see attached).
Thank you, John

#### Attachments

• 75.5 KB Views: 217

#### Diane Poremsky

Senior Member
The macro name format - sub whatever (item as outlook.mailitem) - indicates it's a macro that is called by a rule using run a script action.

To test it with out using a rule or sending messages (or if you just want to run it manually) use this to call it - change YourMacroName to the name of your run a script macro - it will run on the selected message.

Code:
Sub RunScript()
Dim objApp As Outlook.Application
Dim objItem As Object ' MailItem
Set objApp = Application
Set objItem = objApp.ActiveExplorer.Selection.Item(1)

'macro name you want to run goes here
YourMacroName objItem

End Sub
The macros at VBA Sample: Do Something When Reply is Clicked run everytime you click reply, repluall, or forward. some of the samples only show reply - copy the reply macro and change the name for replyall or forward

Copy:
Private Sub oItem_Reply(ByVal Response As Object, Cancel As Boolean)
' bunch of code
end sub

then change reply to replyall or forward in the name and in the set line.

#### John Booze

New Member
The macro name format - sub whatever (item as outlook.mailitem) - indicates it's a macro that is called by a rule using run a script action.

To test it with out using a rule or sending messages (or if you just want to run it manually) use this to call it - change YourMacroName to the name of your run a script macro - it will run on the selected message.

Code:
Sub RunScript()
Dim objApp As Outlook.Application
Dim objItem As Object ' MailItem
Set objApp = Application
Set objItem = objApp.ActiveExplorer.Selection.Item(1)

'macro name you want to run goes here
YourMacroName objItem

End Sub
The macros at VBA Sample: Do Something When Reply is Clicked run everytime you click reply, repluall, or forward. some of the samples only show reply - copy the reply macro and change the name for replyall or forward

Copy:
Private Sub oItem_Reply(ByVal Response As Object, Cancel As Boolean)
' bunch of code
end sub

then change reply to replyall or forward in the name and in the set line.
The macro name format - sub whatever (item as outlook.mailitem) - indicates it's a macro that is called by a rule using run a script action.

To test it with out using a rule or sending messages (or if you just want to run it manually) use this to call it - change YourMacroName to the name of your run a script macro - it will run on the selected message.

Code:
Sub RunScript()
Dim objApp As Outlook.Application
Dim objItem As Object ' MailItem
Set objApp = Application
Set objItem = objApp.ActiveExplorer.Selection.Item(1)

'macro name you want to run goes here
YourMacroName objItem

End Sub
The macros at VBA Sample: Do Something When Reply is Clicked run everytime you click reply, repluall, or forward. some of the samples only show reply - copy the reply macro and change the name for replyall or forward

Copy:
Private Sub oItem_Reply(ByVal Response As Object, Cancel As Boolean)
' bunch of code
end sub

then change reply to replyall or forward in the name and in the set line.
The macro name format - sub whatever (item as outlook.mailitem) - indicates it's a macro that is called by a rule using run a script action.

To test it with out using a rule or sending messages (or if you just want to run it manually) use this to call it - change YourMacroName to the name of your run a script macro - it will run on the selected message.

Code:
Sub RunScript()
Dim objApp As Outlook.Application
Dim objItem As Object ' MailItem
Set objApp = Application
Set objItem = objApp.ActiveExplorer.Selection.Item(1)

'macro name you want to run goes here
YourMacroName objItem

End Sub
The macros at VBA Sample: Do Something When Reply is Clicked run everytime you click reply, repluall, or forward. some of the samples only show reply - copy the reply macro and change the name for replyall or forward

Copy:
Private Sub oItem_Reply(ByVal Response As Object, Cancel As Boolean)
' bunch of code
end sub

then change reply to replyall or forward in the name and in the set line.
The macro name format - sub whatever (item as outlook.mailitem) - indicates it's a macro that is called by a rule using run a script action.

To test it with out using a rule or sending messages (or if you just want to run it manually) use this to call it - change YourMacroName to the name of your run a script macro - it will run on the selected message.

Code:
Sub RunScript()
Dim objApp As Outlook.Application
Dim objItem As Object ' MailItem
Set objApp = Application
Set objItem = objApp.ActiveExplorer.Selection.Item(1)

'macro name you want to run goes here
YourMacroName objItem

End Sub
The macros at VBA Sample: Do Something When Reply is Clicked run everytime you click reply, repluall, or forward. some of the samples only show reply - copy the reply macro and change the name for replyall or forward

Copy:
Private Sub oItem_Reply(ByVal Response As Object, Cancel As Boolean)
' bunch of code
end sub

then change reply to replyall or forward in the name and in the set line.
The macro name format - sub whatever (item as outlook.mailitem) - indicates it's a macro that is called by a rule using run a script action.

To test it with out using a rule or sending messages (or if you just want to run it manually) use this to call it - change YourMacroName to the name of your run a script macro - it will run on the selected message.

Code:
Sub RunScript()
Dim objApp As Outlook.Application
Dim objItem As Object ' MailItem
Set objApp = Application
Set objItem = objApp.ActiveExplorer.Selection.Item(1)

'macro name you want to run goes here
YourMacroName objItem

End Sub
The macros at VBA Sample: Do Something When Reply is Clicked run everytime you click reply, repluall, or forward. some of the samples only show reply - copy the reply macro and change the name for replyall or forward

Copy:
Private Sub oItem_Reply(ByVal Response As Object, Cancel As Boolean)
' bunch of code