MS Word 2003 VBA 删除图形对象
我有一个宏,可以为不同产品的列表生成案例标签。有些产品是无菌的,需要在标签上画一个圆圈作为辐射指示点的位置。圆圈内还有一个文本框,将圆圈标记为点的位置。我尝试通过插入一个圆圈的自动形状并将其设为书签,然后使用代码:
ThisDocument.Bookmarks("GammaDot").Range.Delete
删除所有非无菌部分上的圆圈来做到这一点。此代码用于删除圆圈内文本框中的文本,但圆圈本身不会被删除。 文本框本身似乎也没有被删除,只是框内的文本被删除。 bookmarks.Delete 命令对实际对象不起作用吗?如果没有,我将如何删除圆圈和文本框? 谢谢
I have a macro that generates a case label for a list of different products. Some of the products are sterile and require a drawing of a circle to be placed on the label as a location for a radiation indicator dot. There is also a text box inside the circle that labels the circle as the location for the dot. I tried to do this by inserting an autoshape of a circle and making it a bookmark and then using the code:
ThisDocument.Bookmarks("GammaDot").Range.Delete
to delete the circle on all the parts that aren't sterile. This code works to delete the text from the text box inside the circle, but the circle itself doesn't get deleted.
It also seems that the text box itself isn't getting deleted, just the text inside the box. Does the bookmarks.Delete command not work on actual obects? and if it doesn't, how would I go about deleting the circle and text box?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我怀疑您必须按名称或循环删除形状。书签父级返回文档,而不是文本框。这将删除文本框和圆圈:
I suspect you will have to either delete the shapes by name or in a loop. The bookmark parent returns the document, not the textbox. This will delete both the textbox and the circle:
您可以使用书签 Range 的 ShapeRange 属性来获取属于书签的形状,并使用其 TextFrame 来获取形状的文本:
删除形状也会删除包含的文本。
You can get hold of the shapes belonging to a bookmark using the ShapeRange property of the bookmark's Range, and the shape's text using its TextFrame:
Deleting the shape will also remove the contained text.
您可以通过在 vba 编辑器中运行以下代码来删除除文本及其格式之外的所有内容:
Sub DeleteAllExceptText()
End Sub
You can delete everything except text and its formatting by running following code in vba editor:
Sub DeleteAllExceptText()
End Sub