vba - Visio VBA 更改图片
问题描述
试图在 Visio 组织结构图中更改此人的图片。我可以通过手动单击“更改图片”并浏览来更改它,但是 ChangePicture 方法给了我一个错误。
Sub changeShapePicture(ByRef thisShape As Visio.Shape, filepath as string)
If Dir(filepath) <> "" Then
Debug.Print "File Exists"
thisShape.ChangePicture(filepath)
Else
Debug.Print "Picture File Doesn't Exist"
End If
我收到“此操作的目标对象不合适”的错误。
该方法表示它将图片高度/宽度比作为双精度值返回。
也试过
dim myRatio as double
myRatio = thisShape.ChangePicture(fullPicPath)
并得到同样的错误。
尝试记录宏没有产生有用的代码。
大多数组织框都有在创建组织结构图时导入的图片。但是,由于谁向谁报告的奇怪安排,需要在辅助操作中添加一些框,这就是我试图自动化的。
任何帮助表示赞赏。
解决方案
弄清楚了。在预定义的组织结构图形状中更改图片的解决方案是使用 Add On
Sub changeShapePicture(ByRef thisShape As Visio.Shape, filePath as string)
dim sendTheseKeys as string
sendTheseKeys = filePath + "{ENTER}"
ActiveWindow.Select thisShape, visDeselectAll + visSelect
Dim adn As Visio.Addon
Set adn = Visio.Addons("OrgC11")
SendKeys sendTheseKeys,False
adn.Run "/cmd=ChangePicture"
end sub
现在完美运行。
推荐阅读
- r - 通过用其平均值或中值替换每个箱来去除 R 中具有相等深度分箱的噪声
- java - 我们可以创建具有通用返回类型的方法吗?这如何评估在编译时返回哪种类型?
- excel - VBA - 将文件转换为csv格式后缺少完成0的代码
- django - 使用 Django Rest Framework 将输入文件从 Vue.js 发送到 Django 时出现问题
- python - for循环删除不在python数组中的值
- pip - “pip install tox”给出找到现有安装:filelock 2.0.12
- python - 来自相机的 Python OpenCV 流式传输 - 多线程、时间戳
- swift - TableView Cell 的高度不会根据 WebView 动态变化
- ruby-on-rails - Rails Active Storage + AWS Rekognition:如何获取 IO 文件
- c++ - C++ 的模块标准是否解决了对调用者隐藏私有数据的问题?