Post by drcard on Jan 15, 2024 9:05:54 GMT -5
Hi All,
This tip isn’t for all users, but if you manually run a rule in Outlook on a regular basis, then this tip may be of benefit to you.
This tip is a follow up for a prior tip in a separate posting.
The instructions refer to screenshots “below” where the word “below” is a link to that screenshot. This forum doesn’t allow the links within a document and all the images. If you desire to see the linkable screenshots to better understand the instructions you can download the pdf version of this tip at the following link:
Run an Outlook Rule With Two Clicks
This is a free hosting site which means that a pop up ad will occur when you click to download the pdf file. Just close the pop up window and download is very quick.
Run an Outlook Rule With Two Clicks
What
Instructions to create a macro that will manually run a rule with just two clicks and how to use that macro you created. See Security Considerations below.
Security Considerations:
Most users know it is a security risk to allow Outlook to run macros you don’t know for sure is safe, so they set Outlook’s security settings to disable (aka: don’t run) macros. You can safely run a macro you know is safe and still keep Outlook’s settings to protect you from other macros as explained in the instructions below. Don’t let fear of macros prevent you from using their labor saving advantages.
Why
Only rules set to run in the Inbox folder can be ran automatically when emails are downloaded. Rules that run in any other folder must be ran manually which is a multi-step process. Manually running a rule with only two clicks saves a lot of time and clicks; how much depends on how often you manually run that rule.
Note: The instructions and screenshots are from Outlook 2019 but should work with many other versions of Outlook.
How
Notice: Click the red colored text in the instructions to see the screenshot it refers to. Click the red colored “here” in the return statement below the screenshot to return to the instructions exactly where you left to view the screenshot.
Step 1: Add Developer Tab to Outlook Ribbon
o In Outlook, right click anywhere on the Ribbon and select Customize the Ribbon... which will open Outlook Options to the Customize Ribbon page as shown below.
o In the large box under Customize the Ribbon, scroll down to display the Developer tab. Click the Developer tab to place a checkmark in the box next to it which adds that tab to the Ribbon.
o Click OK to save your changes and close the Options window.
Step 2: Set Macro Security Level
o In order to create a macro in Outlook, the macro security level must be set to allow macros with or without notification. The following explains how to access and select the correct macro security level for running safe macros but not running all macros for security.
o In Outlook, select the Developer tab. In the Code group to the left of the tab, select Macro Security which will open Outlook’s Trust Center to the Macros Settings page as shown below.
o Select Notifications for all macros which will make the circle to the left of the setting to have a blue outline indicating it is selected. This setting will block any macro from running but will present a message window requiring your approval to enable (run) the macro. I do NOT recommend using the Enable all macros settings as this is a big security risk of running malware code.
o Click OK to save your changes and close the Trust Center window.
o Security Note: Once you select Enable Macros in the notification to run your macro, Outlook will run any macro for the rest of that session (until Outlook is closed). After you have finished with the macro close Outlook to reset the security to notification and block macros until you enable them.
Step 3: Create the Macro
These instructions are based upon this being the first macro entered into your Outlook and the rule you want the macro to run is already made and named.
o In Outlook select the Developer tab of the Ribbon. In the Code group to the left of the tab, select Visual Basic which will cause the Microsoft Outlook Security Notice box to open as shown below. Click Enable Macros and the box will close and the Visual Basic Editor will open.
o In the left pane, click ThisOutlookSession to highlight it. Press and release the following keys in this order: Alt, I, M. This will insert a Module which is the coding box for this macro. This opens a text box in the right pane for entering the coding for the macro as shown below.
o Look at the following coding. Note the places in the coding where XXXX in bold green text occurs (3 places). Replace the XXXX with the exact name of the rule making sure that any text or characters immediately before or after the XXXX remains.
Sub RunXXXX()
Dim st As Outlook.Store
Dim myRules As Outlook.Rules
Dim rl As Outlook.Rule
Dim RunRule As String
Dim rulename As String
rulename = "XXXX"
Set st = Application.Session.DefaultStore
Set myRules = st.GetRules
Set cf = Application.ActiveExplorer.CurrentFolder
For Each rl In myRules
If rl.RuleType = olRuleReceive Then
If rl.Name = rulename Then
rl.Execute ShowProgress:=True, Folder:=cf
RunRule = rl.Name
End If
End If
Next
ruleList = "Rule was ran correctly:" & vbCrLf & RunRule
MsgBox ruleList, vbInformation, "Macro: XXXX_Ended"
Set rl = Nothing
Set st = Nothing
Set myRules = Nothing
End Sub
o After you replaced the XXXX with the name of your rule, copy and paste the coding into the text box (labeled Module 1(code)). The screenshot is a Module 2(code) that was made after the fact for these instructions.
o Click the X in the top right corner to close the Visual basic Editor (saves your work automatically).
o Click the dropdown arrow for Macros on the Developer tab and you will see your new macro listed as Project1.RunXXXX (where XXXX is the name of your rule).
Step 4: Run the Macro
o Rules run in a folder and in order for a macro to run a rule you must select the folder for the rule to run in before running the macro to run that rule. Example: A rule to move emails of certain email addresses from the Spam folder to another folder must be ran in the Spam folder.
o In the left navigation pane select the folder that you want the rule to run in (Spam folder for the above example).
o Select the Developer tab, click the dropdown arrow for Macros and select your Macro to run that rule. If this is the first time you access a macro for this open session of Outlook, the notification will pop up requiring you to select Enable Macros to run the macro. The notification only opens on the first macro access per open session.
o The coding includes a notification that the macro ran OK and has stopped so you know it ran, which is not a feature when you manually run a rule.
Step 5: Faster Way to Run the Macro
o If you will use this macro often, then you can make its use easier and faster.
o Right click the Quick Access Toolbar in the upper left corner of the Outlook window and select Customize Quick Access Toolbar... which opens Outlook Options to the Quick Access Toolbar page as shown below.
o In the box below Choose commands from: click the dropdown arrow and select Macros as shown below.
o This will show the macro you created as shown below. Highlight that macro and press the Add button to move that command to the Quick Access Toolbar.
o All macros will have the same icon, so it is best to select an icon that represents this macro as follows.
o Highlight this macro in the Customize Quick Access Toolbar box and click the Modify below to open the Modify Button window (aka: select a different icon window) as shown below. Select the icon that represents what the macro does and click the OK button. I chose a halt hand to remind me to check the Spam folder before I close Outlook.
o Click OK to close the Options window and the new macro icon will display in the Quick Access Toolbar above as shown below.
o Now to run the macro it is one click to select the Spam folder and one click of the macro button in the Quick Access Toolbar to run the macro that runs the rule that checks the Spam folder. Add an additional click if this is the first use of a macro for this open session.
Comments
This is part of a normal routine using a macro safely:
I open Outlook and download my emails.
Handle all emails in the Inbox.
Access the Spam folder.
Run the macro that runs my rule that checks the Spam folder for sender email addresses that are not spam and move those emails to the Inbox.
Check Inbox for any emails moved from Spam folder and handle them.
I don’t delete the Spam emails as I have that folder set to automatically delete all emails over 1 day old.
Close Outlook before any more emails can download while macros are enabled which will reset to block macros when I reopen Outlook.
This tip isn’t for all users, but if you manually run a rule in Outlook on a regular basis, then this tip may be of benefit to you.
This tip is a follow up for a prior tip in a separate posting.
The instructions refer to screenshots “below” where the word “below” is a link to that screenshot. This forum doesn’t allow the links within a document and all the images. If you desire to see the linkable screenshots to better understand the instructions you can download the pdf version of this tip at the following link:
Run an Outlook Rule With Two Clicks
This is a free hosting site which means that a pop up ad will occur when you click to download the pdf file. Just close the pop up window and download is very quick.
Run an Outlook Rule With Two Clicks
What
Instructions to create a macro that will manually run a rule with just two clicks and how to use that macro you created. See Security Considerations below.
Security Considerations:
Most users know it is a security risk to allow Outlook to run macros you don’t know for sure is safe, so they set Outlook’s security settings to disable (aka: don’t run) macros. You can safely run a macro you know is safe and still keep Outlook’s settings to protect you from other macros as explained in the instructions below. Don’t let fear of macros prevent you from using their labor saving advantages.
Why
Only rules set to run in the Inbox folder can be ran automatically when emails are downloaded. Rules that run in any other folder must be ran manually which is a multi-step process. Manually running a rule with only two clicks saves a lot of time and clicks; how much depends on how often you manually run that rule.
Note: The instructions and screenshots are from Outlook 2019 but should work with many other versions of Outlook.
How
Notice: Click the red colored text in the instructions to see the screenshot it refers to. Click the red colored “here” in the return statement below the screenshot to return to the instructions exactly where you left to view the screenshot.
Step 1: Add Developer Tab to Outlook Ribbon
o In Outlook, right click anywhere on the Ribbon and select Customize the Ribbon... which will open Outlook Options to the Customize Ribbon page as shown below.
o In the large box under Customize the Ribbon, scroll down to display the Developer tab. Click the Developer tab to place a checkmark in the box next to it which adds that tab to the Ribbon.
o Click OK to save your changes and close the Options window.
Step 2: Set Macro Security Level
o In order to create a macro in Outlook, the macro security level must be set to allow macros with or without notification. The following explains how to access and select the correct macro security level for running safe macros but not running all macros for security.
o In Outlook, select the Developer tab. In the Code group to the left of the tab, select Macro Security which will open Outlook’s Trust Center to the Macros Settings page as shown below.
o Select Notifications for all macros which will make the circle to the left of the setting to have a blue outline indicating it is selected. This setting will block any macro from running but will present a message window requiring your approval to enable (run) the macro. I do NOT recommend using the Enable all macros settings as this is a big security risk of running malware code.
o Click OK to save your changes and close the Trust Center window.
o Security Note: Once you select Enable Macros in the notification to run your macro, Outlook will run any macro for the rest of that session (until Outlook is closed). After you have finished with the macro close Outlook to reset the security to notification and block macros until you enable them.
Step 3: Create the Macro
These instructions are based upon this being the first macro entered into your Outlook and the rule you want the macro to run is already made and named.
o In Outlook select the Developer tab of the Ribbon. In the Code group to the left of the tab, select Visual Basic which will cause the Microsoft Outlook Security Notice box to open as shown below. Click Enable Macros and the box will close and the Visual Basic Editor will open.
o In the left pane, click ThisOutlookSession to highlight it. Press and release the following keys in this order: Alt, I, M. This will insert a Module which is the coding box for this macro. This opens a text box in the right pane for entering the coding for the macro as shown below.
o Look at the following coding. Note the places in the coding where XXXX in bold green text occurs (3 places). Replace the XXXX with the exact name of the rule making sure that any text or characters immediately before or after the XXXX remains.
Sub RunXXXX()
Dim st As Outlook.Store
Dim myRules As Outlook.Rules
Dim rl As Outlook.Rule
Dim RunRule As String
Dim rulename As String
rulename = "XXXX"
Set st = Application.Session.DefaultStore
Set myRules = st.GetRules
Set cf = Application.ActiveExplorer.CurrentFolder
For Each rl In myRules
If rl.RuleType = olRuleReceive Then
If rl.Name = rulename Then
rl.Execute ShowProgress:=True, Folder:=cf
RunRule = rl.Name
End If
End If
Next
ruleList = "Rule was ran correctly:" & vbCrLf & RunRule
MsgBox ruleList, vbInformation, "Macro: XXXX_Ended"
Set rl = Nothing
Set st = Nothing
Set myRules = Nothing
End Sub
o After you replaced the XXXX with the name of your rule, copy and paste the coding into the text box (labeled Module 1(code)). The screenshot is a Module 2(code) that was made after the fact for these instructions.
o Click the X in the top right corner to close the Visual basic Editor (saves your work automatically).
o Click the dropdown arrow for Macros on the Developer tab and you will see your new macro listed as Project1.RunXXXX (where XXXX is the name of your rule).
Step 4: Run the Macro
o Rules run in a folder and in order for a macro to run a rule you must select the folder for the rule to run in before running the macro to run that rule. Example: A rule to move emails of certain email addresses from the Spam folder to another folder must be ran in the Spam folder.
o In the left navigation pane select the folder that you want the rule to run in (Spam folder for the above example).
o Select the Developer tab, click the dropdown arrow for Macros and select your Macro to run that rule. If this is the first time you access a macro for this open session of Outlook, the notification will pop up requiring you to select Enable Macros to run the macro. The notification only opens on the first macro access per open session.
o The coding includes a notification that the macro ran OK and has stopped so you know it ran, which is not a feature when you manually run a rule.
Step 5: Faster Way to Run the Macro
o If you will use this macro often, then you can make its use easier and faster.
o Right click the Quick Access Toolbar in the upper left corner of the Outlook window and select Customize Quick Access Toolbar... which opens Outlook Options to the Quick Access Toolbar page as shown below.
o In the box below Choose commands from: click the dropdown arrow and select Macros as shown below.
o This will show the macro you created as shown below. Highlight that macro and press the Add button to move that command to the Quick Access Toolbar.
o All macros will have the same icon, so it is best to select an icon that represents this macro as follows.
o Highlight this macro in the Customize Quick Access Toolbar box and click the Modify below to open the Modify Button window (aka: select a different icon window) as shown below. Select the icon that represents what the macro does and click the OK button. I chose a halt hand to remind me to check the Spam folder before I close Outlook.
o Click OK to close the Options window and the new macro icon will display in the Quick Access Toolbar above as shown below.
o Now to run the macro it is one click to select the Spam folder and one click of the macro button in the Quick Access Toolbar to run the macro that runs the rule that checks the Spam folder. Add an additional click if this is the first use of a macro for this open session.
Comments
This is part of a normal routine using a macro safely:
I open Outlook and download my emails.
Handle all emails in the Inbox.
Access the Spam folder.
Run the macro that runs my rule that checks the Spam folder for sender email addresses that are not spam and move those emails to the Inbox.
Check Inbox for any emails moved from Spam folder and handle them.
I don’t delete the Spam emails as I have that folder set to automatically delete all emails over 1 day old.
Close Outlook before any more emails can download while macros are enabled which will reset to block macros when I reopen Outlook.