怎样使用VBA添加图片背景批注?
1、首先在开发工具中打开VBA编辑器
2、在单元格区域当中输入一些内容作为例子
3、在VBA编辑器中插入模块
4、在模块当中输入如下代码,然后运行
Sub 插入图片标注()
Dim pizhu, pic As String
Set pizhu=ActiveCell.Comment
If Not pizhu Is Nothing Then ActiveCell.Comment.Delete '已有批注则删除批注
Set pizhu=Nothing '释放变量
pic=Application.GetOpenFilename(ImgFileformat) '提取图片文件
If pic="False" Then End '选择取消则退出程序
With ActiveCell
.AddComment '添加批注
.Comment.Visible=False '批注不可见
.Comment.Shape.Fill.Transparency=0# '批注不透明
.Comment.Shape.Fill.UserPicture pic '填充图片
.Comment.Shape.LockAspectRatio=msoTrue '设定图片透明度
.Comment.Shape.Height=30# '设定批注高度为30
End With
ActiveCell.Select
'设置图片比例,高与宽之比为3∶4
ActiveCell.Comment.Shape.ScaleWidth 3, msoFalse, msoScaleFromTopLeft
ActiveCell.Comment.Shape.ScaleHeight 4, msoFalse, msoScaleFromTopLeft
End Sub
5、选择照片,并单击“确定”按钮返回工作表,单元格A3即已完成图片批注的插入
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:174
阅读量:23
阅读量:88
阅读量:115
阅读量:95