使用按钮在当前单元格的右侧添加并偏移形状
在下面的VBA代码中,代码的目标是每次在当前单元格的右侧添加形状。我也在下面添加了一个GIF,因此您可以准确地看到我想做什么。我的代码现在立即导致运行时错误。我知道我必须以某种方式使用偏移命令。
Sub FormButtonClick()
Set myDocument = Worksheets(1)
myDocument.Shapes.AddShape msoShapeRectangle, 50, 50, 100, 200
myDocument.Left
End Sub
In my vba code below the goal of the code is to add shape every time to the right of the current cell. I added a gif below as well so you can see exactly what I would like to do. My code below right now causes a runtime error. I know I somehow have to use the offset command.
Sub FormButtonClick()
Set myDocument = Worksheets(1)
myDocument.Shapes.AddShape msoShapeRectangle, 50, 50, 100, 200
myDocument.Left
End Sub
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的解决方案必须有几次检查才能按照您的要求添加形状:
您必须在下面的示例代码中进行一些细节,但是您应该能够扩展示例以满足您的需求。
该示例做出以下假设:
代码:
Your solution must have several checks in order to add the shapes as you desire:
There are a few details that you'll have to dig out in the example code below, but you should be able to expand the example to fit your needs.
The example makes the following assumptions:
The code: