Excel:使用vba添加注释作者 [英] Excel: Add comment author using vba
本文介绍了Excel:使用vba添加注释作者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我手动向单元格添加注释时(使用insert comment命令),文本的前面是用粗体字的用户名。
When I add comments to a cell manually (using the insert comment command) the text is preceded by my username in bold font.
在 vba 中使用 Range.AddComment()
(对于运行宏的用户)
Is it possible to replicate this characteristic for comments created in vba using Range.AddComment()
(for whichever user is running the macro) ?
推荐答案
可以添加登录的用户名(用户名以粗体显示),例如单元格A1:
You can add the logged in user name (with the user name in bold) like so - this example for cell A1:
Sub EasyTest()
Dim shCmt As Comment
On Error Resume Next
Set shCmt = [a1].Comment
On Error GoTo 0
If shCmt Is Nothing Then
Set shCmt = [a1].AddComment
shCmt.Text Text:=Environ$("UserName") & Chr(10) & "TestMe"
shCmt.Shape.TextFrame.Characters(1, Len(Environ$("UserName"))).Font.Bold = True
Else
MsgBox "cell already has a comment"
End If
End Sub
这篇关于Excel:使用vba添加注释作者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文