VBA Email notification

galmond1010

New Member
Joined
Apr 15, 2019
Messages
17
Is it possible to have an email notification when one of my files is open by another user? I have used MsgBox and With Outmail code before but it was when someone ran my macro. I wasn't sure if it can be done with my file is opened. Thank you in advance.
 

Kamolga

Well-known Member
Joined
Jan 28, 2015
Messages
1,162
There is an open workbook event: In VBA, 2x click "ThisWorkbook" under the sheets name and paste

Code:
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]Private Sub Workbook_Open()
 With ActiveSheet.MailEnvelope
        .Introduction = "File 123 was opened"
        .Item.To = "myemail@adress.com
        .Item.Subject = "I opened your file"
    'Chose display or send
        '.Item.display
        .Item.send
    End With
End Sub[/FONT]
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
51,499
Office Version
365
Platform
Windows
Just note that they can get around this by disabling Macros/VBA when opening the workbook.

What I have seen some people do is hide and protect the sheet so that no data is shown, by default, and to have code to unhide it in the same Workbook_Open event procedure code. That way, if they do open it with disabling VBA, it is essentially worthless to them, as they will not see anything.
 
Last edited:

Forum statistics

Threads
1,082,441
Messages
5,365,542
Members
400,837
Latest member
ELMST616

Some videos you may like

This Week's Hot Topics

Top