简体   繁体   中英

Excel VBA macro to pull name of file to body of automatic email

I have a macro that sends an email to management whenever someone opens the file. In the body of the email it includes their User ID but I would also like to have it display the name of the file that was opened. Below is my code that auto composes the email:

mItem.Subject = "RLS Report Opened"
mItem.Body = "This is an automated message to inform you that " & _
             Environ("username") & " has downloaded and is using the file."

I would like the filename to be inserted "...has downloaded and is using the file [filename here]."

使用ActiveWorkbook.FullName ,它将返回包括名称的完整文件路径,或者使用ActiveWorkbook.Name ,将仅返回文件名称。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM