如何将形状存储到变量中?
以下 Visio 宏(使用 VBA)旋转当前选定的形状:
ActiveWindow.Selection.Rotate90
如何将该形状存储到变量中?我尝试了下面的代码。
Dim s1 as Shape
Let s1 = ActiveWindow.Selection
s1.Rotate90
该代码无法编译,它在“选择”上给我一个“参数不可选”错误。
如果我将其更改为 Selection(0),我会收到运行时错误“无效的选择标识符”。
如果我尝试 Selection(1),我会得到“对象变量或未设置块变量”,我猜这是 VBA 抱怨选择中只有一个对象的方式。
The following Visio macro (using VBA) rotates the currently selected shape:
ActiveWindow.Selection.Rotate90
How can I store that shape into a variable? I tried the code below.
Dim s1 as Shape
Let s1 = ActiveWindow.Selection
s1.Rotate90
That code does not compile, it gives me a "argument not optional" error on "Selection".
If I change it to Selection(0) I get the runtime error "Invalid selection identifier".
If I try Selection(1) I get instead "Object variable or With block variable not set", which I'm guessing is VBA's way of complaining that there is only one object in the selection.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这里应该使用 Set 而不是 Let。
You should use Set instead of Let here.
与使用 Set 而不是 Let 一样,选择也是一个选择对象,而不是一个形状。你可以使用:
As well as using Set instead of Let, the selection is a selection object, not a shape. You could use: