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

• VBA07142017.JPG
75.5 KB · Views: 481

#### 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
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?

Status
Not open for further replies.
Thread starter Title Forum Replies Date
Outlook Rules VBA Run a Script - Multiple Rules Outlook VBA and Custom Forms 0
Outlook 2019 VBA run-time error 424 Outlook VBA and Custom Forms 2
Auto Run VBA Code on new email Outlook VBA and Custom Forms 1
VBA Macro - Run-time error '424': object required - Help Please Outlook VBA and Custom Forms 3
Run Time Error 91 when linking contact to task in VBA Outlook VBA and Custom Forms 1
VBA to Run Font Change on Outlook Startup Outlook VBA and Custom Forms 4
Creating an outlook session from Access vba but run silently. With A specific profile Outlook VBA and Custom Forms 1
modify vba to run it as script rule Outlook VBA and Custom Forms 8
How many subs can run in one outlook VBA script Using Outlook 5
Outlook 2003 VBA Won't Run In Outlook 2010 Outlook VBA and Custom Forms 4
Outlook 2013 VBA to run a rule Outlook VBA and Custom Forms 13
Vba script including macro appears in rules but wont run Outlook VBA and Custom Forms 6
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
Outlook (desktop app for Microsoft365) restarts every time I save my VBA? Using Outlook 0
VBA Macro to Print and Save email to network location Outlook VBA and Custom Forms 1
Small vba to kill political email Outlook VBA and Custom Forms 3
Outlook 365 Outlook/VBA Outlook VBA and Custom Forms 11
VBA Macro To Save Emails Outlook VBA and Custom Forms 1
VBA Forward vs manual forward Outlook VBA and Custom Forms 2
VBA Cannot programmatically input or change Value for User Defined field Using Outlook 1
VBA for outlook to compare and sync between calendar Outlook VBA and Custom Forms 1
Any way to force sort by/group by on search results with VBA? Outlook VBA and Custom Forms 1
Default shape via VBA Outlook VBA and Custom Forms 4
Change settings Send/receive VBA Outlook VBA and Custom Forms 0
Import Tasks from Access Using VBA including User Defined Fields Outlook VBA and Custom Forms 0
Outlook VBA change GetDefaultFolder dynamically Outlook VBA and Custom Forms 6
How to set a flag to follow up using VBA - for addressee in TO field Outlook VBA and Custom Forms 11
add new attendee to existing meetings with VBA Outlook VBA and Custom Forms 5
VBA code to select a signature from the signatures list Outlook VBA and Custom Forms 3
Create advanced search (email) via VBA with LONG QUERY (>1024 char) Outlook VBA and Custom Forms 2
VBA to manually forward using odd options Outlook VBA and Custom Forms 1
Need help modifying a VBA script for in coming emails to auto set custom reminder time Outlook VBA and Custom Forms 0
vba outlook search string with special characters Outlook VBA and Custom Forms 1
VBA search string with special characters Outlook VBA and Custom Forms 1
VBA to Auto Insert Date and Time in the signature Outlook VBA and Custom Forms 2
VBA to move email from Non Default folder to Sub folders as per details given in excel file Outlook VBA and Custom Forms 11
VBA to save selected Outlook msg with new name in selected network Windows folder Outlook VBA and Custom Forms 1
Excel VBA to move mails for outlook 365 on secondary mail account Outlook VBA and Custom Forms 1
Zoom automatically next email item (VBA) Outlook VBA and Custom Forms 2
vba extract data from msg file as attachment file of mail message Outlook VBA and Custom Forms 1
Outlook Office 365 VBA download attachment Outlook VBA and Custom Forms 2
VBA Script - Print Date between first email in Category X and last email in Category Y Outlook VBA and Custom Forms 3
Help creating a VBA macro with conditional formatting to change the font color of all external emails to red Outlook VBA and Custom Forms 5
Save selected messages VBA does not save replies and/or messages that contain : in subject Outlook VBA and Custom Forms 1
Filter unread emails in a search folder vba help Outlook VBA and Custom Forms 0
vBA for searching a cell's contents in Outlook and retrieving the subject line Outlook VBA and Custom Forms 1
vBA for exporting excel file from outlook 2016 Outlook VBA and Custom Forms 3
Modifying VBA script to delay running macro Outlook VBA and Custom Forms 3