找出一个叫做macros的工作簿

我在工作簿ABC中有一个macros。 我想知道其他工作簿正在调用这个macros,因为我们将要replace它的function。 有没有办法来告诉什么工作簿正在调用macros执行? 还是Application.Run隐藏从被调用的macros?

我不知道如何获得工作簿的名称。 您可以login工作站和用户,然后转到工作站并启动Excel,然后转到“文件” – >“最近”,以查看计算机上使用的最新工作簿。

您可以将日志文件写入到包含该macros的工作簿的位置。

像这样的东西从macros中调用。

在你的VBA IDE中,进入工具菜单并select引用。 select“Microsoft脚本运行时”

 Private Sub LogUsage() Dim ts As TextStream Dim fs As FileSystemObject Dim strLogFile As String strLogFile = Application.ActiveWorkbook.Path & "\Usage.txt" 'Check if the file exists, if it does, open it, if it doesn't create it Set fs = New FileSystemObject If fs.FileExists(strLogFile) = True Then Set ts = fs.OpenTextFile(strLogFile, ForAppending) Else Set ts = fs.CreateTextFile(strLogFile, True, False) End If 'Log your entry ts.WriteLine "Used by " & Environ$("Username") & " at " & Now & " on computer " & Environ$("Computername") 'Clean up ts.Close: Set ts = Nothing Set fs = Nothing End Sub