vba Excel 2013 - 在字段中插入“用户上次修改”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18280548/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Excel 2013 - Insert "last modified by user" in field
提问by SlyKrysis
I have an inventory checklist that I'm supposed to be maintaining, but we have multiple people in the office that edit and make changes to the document. As a tracking measure, we want to implement a macro that inserts the username of the person who last modified or even opened the file (modified would be better).
我有一个我应该维护的库存清单,但我们办公室里有多个人来编辑和更改文档。作为跟踪措施,我们想要实现一个宏,插入最后修改甚至打开文件的人的用户名(修改后会更好)。
I have already tried inserting the following Auto_Open macro:
我已经尝试插入以下 Auto_Open 宏:
Private Sub Workbook_Open()
Sheets("Inventory List").Range("D31").Value = Environ("username")
End Sub
Where "Inventory List" is the primary worksheet and the cell I want it inserted is D31. I got it to work for my name, but when my coworkers open it and change it, it does not insert their name. I have already saved the file as a macro-enabled worksheet, and they have all allowed and trusted the macro content when they open the file.
其中“库存清单”是主要工作表,我想要插入的单元格是 D31。我让它为我的名字工作,但是当我的同事打开它并更改它时,它没有插入他们的名字。我已经将文件保存为启用宏的工作表,并且他们在打开文件时都允许并信任宏内容。
Anything I'm doing wrong?
我做错了什么吗?
Source used: http://office.microsoft.com/en-us/excel-help/run-a-macro-HA102748985.aspx#_Toc304793168
使用的来源:http: //office.microsoft.com/en-us/excel-help/run-a-macro-HA102748985.aspx#_Toc304793168
回答by S Nash
Sheets("Inventory List").Range("D31").Value = Environ("username") should always work.
Sheets("Inventory List").Range("D31").Value = Environ("username") 应该总是有效的。
Question is where other users open this Excel file. do they open it on their own computer?
问题是其他用户在哪里打开这个 Excel 文件。他们是在自己的电脑上打开的吗?
My strong guess is they have elevated macro security on the computer. Check other users Excel file to see macro security level. Note that this feature does not get copied if you modify in on your own computer and then send it to them.
我强烈的猜测是他们提高了计算机上的宏安全性。检查其他用户的 Excel 文件以查看宏安全级别。请注意,如果您在自己的计算机上进行修改然后将其发送给他们,则不会复制此功能。