我正在尝试创建类似我自己的自动形状的东西,并让Word 2007创建它并自动将这两个形状分组。我已经浏览了整个互联网(谷歌,bing,MSDN目录,Stackoverflow,微软网站)寻找解决方案。我厌倦了创建一个可以在命令中创建我的对象的宏,但每次我仍然得到相同的错误。
ActiveDocument.Shapes.AddShape(msoShapeRoundedRectangle, 331.4, 318.45, _
122.75, 98.8).Select
ActiveDocument.Shapes.AddConnector(msoConnectorStraight, 331.4, 354.45, _
122.75, 0#).Select
ActiveDocument.Shapes.Range(Array("AutoShape 727", "AutoShape 728")). _
Select
Selection.ShapeRange.Group.Select
当我运行此代码时,我收到以下错误: 运行时错误:ShapeRange对象必须至少包含两个项目。
我还想重命名自动形状,但我不知道该怎么做。
感谢您的帮助。
答案 0 :(得分:0)
试试这个
Sub Tester()
Dim s1 As Shape, s2 As Shape, sr As ShapeRange
Set s1 = ActiveDocument.Shapes.AddShape(msoShapeRoundedRectangle, _
331.4, 318.45, 122.75, 98.8)
s1.Name = "Test1"
Set s2 = ActiveDocument.Shapes.AddConnector(msoConnectorStraight, _
331.4, 354.45, 122.75, 0#)
s2.Name = "Test2"
ActiveDocument.Shapes.Range(Array(s1.Name, s2.Name)).Group.Select
End Sub