Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I send an email to see who opens a file?

Status
Not open for further replies.

kalebson

Programmer
Mar 3, 2006
60
US
I am drawing a complete blank here. What I want to do is when someone opens my excel file I want it to send me an email. Just a message saying WHO has opened the file. I have tried many different codes and cant seem to get any to work. Is there a way to do this? If I cant get the email to tell me who can I just get a message sent to me that says it has been opened w/o attaching the workbook? I cant attach the workbook its over 30MB.
 
You can have code run when a file is opened.

You can get the user network logon name when the file is opened.

You can make an instance of Outlook (if that is what is being used for mail), and send an email to yourself, when the file is opened.

What you can NOT do is have this happen without the person knowing about it.

Gerry
 
...but you could create a log file that has the user name (and any other details you decide) appended to it everytime the workbook is opened.

Since the time stamp would be altered every time something is addded to the log file you could right a simple script on your machine (or in Outlook for that matter) that would alert you when the log file has changed...

Food for thought,
CMP

(GMT-07:00) Mountain Time (US & Canada)
 
In form/open zetten
Dim o As Outlook.Application
Dim mail As mailitem
Set o = CreateObject("Outlook.Application")
Set mail = o.CreateItem(olMailItem)
mail.To = "jouw mailadres"
mail.Subject = "Deze persoon heeft aangelogd" & fOSUserName
mail.Body = "Hier kan je eventueel ook nog tekst zetten"
mail.Importance = olImportanceHigh
mail.Display
Set o = Nothing
Set mail = Nothing

Dit zet je in een macro

Option Compare Database
Option Explicit
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long


Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX <> 0 Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = ""
End If
End Function

Dit moet het doen naar mijn weten.

Groetjes
Ed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top