在excel用VBA更改批注的作者

在Excel中,当光标移动到包含批注的单元格中时,通常会在状态栏和批注中显示批注者的名称。如果需要将批注者改为其他人,可以用下面的VBA代码。以后再插入新的批注,也将使用新输入的名称。使用前先将代码中的“新作者”和“原作者”按照需要进行替换。

Sub ChangeCommentName()
Dim ws As Worksheet
Dim cmt As Comment
Dim strOld As String
Dim strNew As String
Dim strComment As String
strNew = "新作者"
strOld = "原作者"
Application.UserName = strNew
For Each ws In ActiveWorkbook.Worksheets
For Each cmt In ws.Comments
strComment = Replace(cmt.Text, strOld, strNew)
cmt.Delete
cmt.Parent.AddComment Text:=strComment
Next cmt
Next ws
End Sub

office办公软件入门基础教程 » 在excel用VBA更改批注的作者

本文链接:【在excel用VBA更改批注的作者】https://www.officeapi.cn/34662.html

OFFICE,天天学一点,进步多一点

联系我们