在VBA中,如何编写添加批注图片代码

时间:2024-10-12 17:28:03

1、实例【编写VBA代码,在批注里添加人员相片?】

在VBA中,如何编写添加批注图片代码

2、在工作表中,点击菜单栏【开发工具】,在其工具栏内,点击【visual basic】!

在VBA中,如何编写添加批注图片代码

3、会进入VBA编辑界面!点击菜单栏【插入】,在其下拉菜单中,选择【模块】!

在VBA中,如何编写添加批注图片代码

4、会弹出模块编辑窗口!

在VBA中,如何编写添加批注图片代码

5、在代码编辑窗口输入以下代码:Sub 添加批注图片()Set rng = Columns("a").End(旌忭檀挢xlDown)For Each arg In Range([a2], rng)paths = thisworkbook.Path & "\tupian\" & arg.Value & ".jpg"With arg If .Comment Is Nothing Then .AddComment .Comment.Shape.Height = 40 .Comment.Shape.Width = 60 .Comment.Shape.Fill.UserPicture paths End IfEnd WithNextEnd Sub

在VBA中,如何编写添加批注图片代码

6、在工作表的【开发工具】菜单下,点击【插入】按钮,插入一【表单】按钮,并与指定编写的晃瓿淀眠【添加批注图片】代码关联,且进入命名为【添加批注相片】!

在VBA中,如何编写添加批注图片代码

7、点击【添加批注相片】按钮,工作表中A栏批注被瞬间添加上去,当光标靠近批注时,会显示人员的相片!

在VBA中,如何编写添加批注图片代码
© 手抄报圈