VBA Run When Reply

Status
Not open for further replies.

John Booze

New Member
Outlook version
Outlook 2013 64 bit
Email Account
Office 365 Exchange
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
 
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

this article shows how to add text if its not in the one above: Run a script rule: Reply to a message

Adding attachments is fairly simple:
oResponse.Attachments.Add "C:\path\to\filename.docx"

signature should be added automatically, if not, i have code at slipstick that does that too.
 
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).
Any advice or links would be appreciated.
Thank you, John
 

Attachments

  • VBA07142017.JPG
    VBA07142017.JPG
    75.5 KB · Views: 576
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
Set oResponse = oItem.Reply
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
Set oResponse = oItem.Reply
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
Set oResponse = oItem.Reply
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
Set oResponse = oItem.Reply
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
Set oResponse = oItem.Reply
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
Set oResponse = oItem.Reply
end sub

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

Hello Diane, I still need help.
1. When working with Outlook and VBA will I always be placing my code within "ThisOutlookSession?"
2. Is this how you are saying to call a Macro(Sub)?
Diane, can you point me to 2 simple codes where I can get the feel of saving and calling different Macro(Sub)s when I am calling routines in Outlook?
I appreciate your quick responses.

upload_2017-7-19_9-12-39.png
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
J Outlook Rules VBA Run a Script - Multiple Rules Outlook VBA and Custom Forms 0
U Outlook 2019 VBA run-time error 424 Outlook VBA and Custom Forms 2
C Auto Run VBA Code on new email Outlook VBA and Custom Forms 1
S VBA Macro - Run-time error '424': object required - Help Please Outlook VBA and Custom Forms 3
P Run Time Error 91 when linking contact to task in VBA Outlook VBA and Custom Forms 1
O VBA to Run Font Change on Outlook Startup Outlook VBA and Custom Forms 4
D Creating an outlook session from Access vba but run silently. With A specific profile Outlook VBA and Custom Forms 1
O modify vba to run it as script rule Outlook VBA and Custom Forms 8
P How many subs can run in one outlook VBA script Using Outlook 5
G Outlook 2003 VBA Won't Run In Outlook 2010 Outlook VBA and Custom Forms 4
Gary Brown Outlook 2013 VBA to run a rule Outlook VBA and Custom Forms 13
P Vba script including macro appears in rules but wont run Outlook VBA and Custom Forms 6
J Outlook 2007 Rules & VBA: How to run a script on a report message (ReportItem) Using Outlook 14
M Run external program from Outlook VBA macro Outlook VBA and Custom Forms 5
L How do I Run Saved Export in Access 2007 VBA? Outlook VBA and Custom Forms 1
H using VBA to edit subject line Outlook VBA and Custom Forms 0
G Get current open draft message body from VBA Outlook VBA and Custom Forms 1
Geldner Problem submitting SPAM using Outlook VBA Form Outlook VBA and Custom Forms 2
P VBA to add email address to Outlook 365 rule Outlook VBA and Custom Forms 0
M Outlook 2016 outlook vba to look into shared mailbox Outlook VBA and Custom Forms 0
V VBA Categories unrelated to visible calendar and Visual appointment Categories Outlook VBA and Custom Forms 2
D Outlook VBA forward the selected email to the original sender’s email ID (including the email used in TO, CC Field) from the email chain Outlook VBA and Custom Forms 2
R Outlook 365 VBA AUTO SEND WITH DELAY FOR EACH EMAIL Outlook VBA and Custom Forms 0
R Outlook 2019 VBA to List Meetings in Rooms Outlook VBA and Custom Forms 0
geoffnoakes Counting and/or listing fired reminders via VBA Using Outlook 1
O VBA - Regex - remove double line spacing Outlook VBA and Custom Forms 1
D.Moore Strange VBA error Outlook VBA and Custom Forms 4
B Modify VBA to create a RULE to block multiple messages Outlook VBA and Custom Forms 0
D Outlook 2021 Using vba code to delete all my spamfolders not only the default one. Outlook VBA and Custom Forms 0
K vba code to auto download email into a specific folder in local hard disk as and when any new email arrives in Inbox/subfolder Outlook VBA and Custom Forms 0
D VBA - unable to set rule condition 'on this computer only' Outlook VBA and Custom Forms 5
L Fetch, edit and forward an email with VBA outlook Outlook VBA and Custom Forms 2
BartH VBA no longer working in Outlook Outlook VBA and Custom Forms 1
W Can vba(for outlook) do these 2 things or not? Outlook VBA and Custom Forms 2
MattC Changing the font of an email with VBA Outlook VBA and Custom Forms 1
P MailItem.To Property with VBA not work Outlook VBA and Custom Forms 2
P Tweak vba so it can target another mailbox Outlook VBA and Custom Forms 1
A Outlook 2010 VBA fails to launch Outlook VBA and Custom Forms 2
richardwing Outlook 365 VBA to access "Other Actions" menu for incoming emails in outlook Outlook VBA and Custom Forms 0
W Create a Quick Step or VBA to SAVE AS PDF in G:|Data|Client File Outlook VBA and Custom Forms 1
C Outlook (desktop app for Microsoft365) restarts every time I save my VBA? Using Outlook 1
D VBA Macro to Print and Save email to network location Outlook VBA and Custom Forms 1
TedSch Small vba to kill political email Outlook VBA and Custom Forms 3
E Outlook 365 Outlook/VBA Outlook VBA and Custom Forms 11
N VBA Macro To Save Emails Outlook VBA and Custom Forms 1
Z VBA Forward vs manual forward Outlook VBA and Custom Forms 2
J VBA Cannot programmatically input or change Value for User Defined field Using Outlook 1
J VBA for outlook to compare and sync between calendar Outlook VBA and Custom Forms 1
A Any way to force sort by/group by on search results with VBA? Outlook VBA and Custom Forms 1
E Default shape via VBA Outlook VBA and Custom Forms 4

Similar threads

Back
Top