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
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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.
 

John Booze

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

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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.
 

John Booze

New Member
Outlook version
Outlook 2013 64 bit
Email Account
Office 365 Exchange
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
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
S Add VBA save code Using Outlook 0
O VBA Cases with Listbox - Can you use Multi-Select? Outlook VBA and Custom Forms 4
O VBA Outlook Message Attachment - Array Index Out of Bounds Outlook VBA and Custom Forms 0
V Modifying the built in forms with VBA Outlook VBA and Custom Forms 4
S Excel VBA and shared calendar issue Outlook VBA and Custom Forms 4
L Macro/VBA to Reply All, with the original attachments Outlook VBA and Custom Forms 2
L VBA unknown character Outlook VBA and Custom Forms 2
G Move tasks up/down todo list by VBA Outlook VBA and Custom Forms 1
diver864 vba for a rule to automatically accept meeting requests with 'vacation' in subject, change to all-day event, change to free, don't send reply Outlook VBA and Custom Forms 1
K Use VBA to find Sender and Recipient from Microsfot 365 Journaled Email Items Outlook VBA and Custom Forms 3
J Want to learn VBA Macros for Outlook. What book can you recommend? Outlook VBA and Custom Forms 2
F VBA code to dock Styles whenever I write or edit an email Outlook VBA and Custom Forms 0
C VBA to prompt for Sent folder destination Outlook VBA and Custom Forms 3
B Adding signature to bottom of VBA reply email Outlook VBA and Custom Forms 1
B Change Font and Font size using VBA Outlook VBA and Custom Forms 9
M Outlook 2013 reminder email by using Outlook vba Outlook VBA and Custom Forms 2
D.Moore VBA script fail after Office 365 update Using Outlook 8
R Limiting length of saved attachment in VBA Outlook VBA and Custom Forms 2
S Skype for business meeting vba code Outlook VBA and Custom Forms 1
C How to use VBA to show only items x days old or more Outlook VBA and Custom Forms 1
B VBA to convert email to task, insert text of email in task notes, and attach copy of original email Outlook VBA and Custom Forms 4
D Outlook VBA error extracting property data from GetRules collection Outlook VBA and Custom Forms 10
S Reference Custom Fields with VBA Outlook VBA and Custom Forms 2
PGSystemTester VBA To Change AppointmentItem.BusyStatus From MeetingItem Before Send Using Outlook 0
A VBA macro for 15 second loop in send and received just for 1 specific mailbox Outlook VBA and Custom Forms 1
O Email not leaving Outbox when using Excel VBA to sync Outlook account Outlook VBA and Custom Forms 4
G VBA Macro Calendar Printing Assistant 4
R Help Revising VBA macro to delete email over different time span Outlook VBA and Custom Forms 0
B VBA to Collapse Task Folder Groups Outlook VBA and Custom Forms 1
R Expand VBA Permanent Delete Code Outlook VBA and Custom Forms 6
shrydvd vba to secure zip attachments Outlook VBA and Custom Forms 3
M Adding Subject to this Link-Saving VBA Outlook VBA and Custom Forms 5
N VBA to delete duplicates by message-id on common pst for 2 or more emails Outlook VBA and Custom Forms 0
S Change VBA script to send HTML email instead of text Outlook VBA and Custom Forms 3
M VBA to auto forward message with new subject and body text Outlook VBA and Custom Forms 8
A Custom VBA to sort emails into folders Outlook VBA and Custom Forms 0
L Moving emails with similar subject and find the timings between the emails using outlook VBA macro Outlook VBA and Custom Forms 1

Similar threads

Top