On outlook application I created a new folder with name “Template”.
Inside that folder, I manually put some emails, with inside it my excel macro workbooks.
Macro settings on Excel are Disable all macros with notification
,
as a result when I open any macro workbook, I got a security warning that macros have been disabled,
and I need to click Enable Content
each time.
I could not find any way to add these files to a trusted location or even make as trusted document.
So, as a work around, I need to change excel macro settings (temporarily) from outlook when opening any email on that folder “Template” to Enable all macros
and after close this email or sent it, then revert macro settings again to “Disable all macros with notification”.
Note 1, Sure, I mean change these macro settings @ my machine only and not at the recipient PC.
Note 2, I already using some macros globally inside outlook (auto zoom), and signed these macros by creating a Digital Signature using SelfCert.exe
، therefore I do not get any security warning when using that macros.
Note 3, I found this question Link, But I could not adapt the provided answer to my needs ,and I use office 2016 32Bit on windows 10 64Bit.
In advance grateful for useful comments and answer.
Public WithEvents myItem As Outlook.MailItem
Public EventsDisable as Boolean
Private Sub Application_ItemLoad(ByVal Item As Object)
If EventsDisable = True Then Exit Sub
If Item.Class = olMail Then
Set myItem = Item
End If
End Sub
Private Sub myItem_Open(Cancel As Boolean)
EventsDisable=True
'Your code
EventsDisable=False
End Sub