EXCEL VBA改变批注的框的大小的方法:
1.打开 excel 工作薄,按下 Alt + F11 键,调出excel的VBA编辑器;
2. 单击菜单栏上的“插入”,打开的菜单单击“模块”命令,如图:
3. 将下面的代码复制到模块框中,这里以将所有批注的宽度改为350为例:
Sub 批量修改批注框宽度()
Dim Cmt As Comment
For Each Cmt In ActiveSheet.Comments
Cmt.Parent.Comment.Shape.Width = 350
Next Cmt
End Sub
4. 单击工具栏绿色的“运行”按钮或直接按F5键;效果如图:
5. 点击右上角关闭按钮 退出VBA编辑器窗口,现在看一下效果图:
这样,就完成了批量修改所有excel批注框大小的任务了。
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 3 Then Exit Sub
With Target
If .Value = "atiendhold@yahoo.com.cn" & Chr(10) & "DIKEIDM@TOMTOM.COM" Then
.AddComment
.Comment.Text Text:="1.This message was transferred with a trial version," & Chr(10) & "2) I will not in the office in Monday,May 16 and will back in Tuesday,May 17." & ""
.Comment.Shape.TextFrame.AutoSize = True
End If
End With
End Sub