excel - 修改 CommentThreaded 时自动运行宏?
问题描述
我有一列,其单元格通过CommentsThreaded和CommentThreaded对象进行评论。在另一个专栏中,我使用函数成功复制了这些线程的内容=GetComments(A1)
,如下图:
' Returns the concatenated string of parent and child comments for the specified input cell.
Function GetComments(SelectedCell As Range) As String
Set CellComment = SelectedCell.CommentThreaded
Dim Result As String
If Not CellComment Is Nothing Then
Result = CellComment.Author.Name & ": """ & CellComment.Text & """ " & vbNewLine & vbNewLine
Dim ChildCount As Integer
ChildCount = 1
For Each ChildComment In CellComment.Replies
Result = Result & "[Reply #" & ChildCount & "] " & ChildComment.Author.Name & ": """ & ChildComment.Text & """ " & vbNewLine & vbNewLine
ChildCount = ChildCount + 1
Next
Else
Result = "No Comments"
End If
GetComments = Result
End Function
示例输出为:John Doe: "My comment"
但是,我注意到当添加/编辑/删除评论时,使用该GetComments
函数的输出单元格不会更新。我必须在输出单元格中手动重新运行该函数,以通过选择它并按下来更新其内容Enter。
我已经尝试使用所有典型的事件处理程序,例如Worksheet.Change
,SelectionChange
等。修改评论时不会触发任何事件。手动强制Volatile
或Calculate
. 这几乎就像CommentsThreaded
根本不包含在工作簿事件中的 Add/Delete/Edit 方法一样。
这可能吗?谢谢!
解决方案
推荐阅读
- .net-core - 从 .net core 2.2 访问 UNC
- javascript - 当 p 标签接近时向下移动元素
- vba - 如何复制一行并粘贴 X 次
- c# - 如何确保 C# WebBrowser 控件中的搜索文本是实际文本而不是元素或属性?
- git - Visual Studio 将 GIT 存储库(本地或远程)发布到开发服务器,而无需更改尚未暂存/提交的文件
- asp.net-core - 创建 ASP.NET Core Web 应用程序时未检测到 .NET Core SDK
- sap - SAP Business 对象如何在不同数据提供者之间创建不同类型的连接
- django - Django RF:从 Leaflet Draw 到 PostGIS 的 POST 几何
- sql-server - 使用 .NET EF CORE,我可以将整个数据库复制到不同的服务器吗?
- java - Spring 瞬态注释适用于保存,但不适用于选择