在Word VBA中指定新内联形状的位置?
我正在为我工作的公司开发一个文档“向导”。 它是一个 .dot 文件,其标头由一些文本和一些表单字段以及大量 VBA 代码组成。 文档正文作为 OLE 对象从单独的 .doc 文件中拉入。
目前,这是作为 Shape
完成的,而不是 InlineShape
。 我这样做是因为我可以绝对定位 Shape,而 InlineShape 始终出现在文档的开头。
这样做的问题是,当标题大小发生变化时,Shape
不会移动。 如果由于特殊情况有人需要在标题中添加或删除一行,他们还需要移动定义正文的对象。 这是一种痛苦,如果可能的话我想避免它。
长话短说,如何在 Word 中使用 VBA 定位 InlineShape
?
我使用的版本是Word 97。
I'm working on a document "wizard" for the company that I work for. It's a .dot file with a header consisting of some text and some form fields, and a lot of VBA code. The body of the document is pulled in as an OLE object from a separate .doc file.
Currently, this is being done as a Shape
, rather than an InlineShape
. I did this because I can absolutely position the Shape, whereas the InlineShape always appears at the beginning of the document.
The problem with this is that a Shape
doesn't move when the size of the header changes. If someone needs to add or remove a line from the header due to a special case, they also need to move the object that defines the body. This is a pain, and I'd like to avoid it if possible.
Long story short, how do I position an InlineShape
using VBA in Word?
The version I'm using is Word 97.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
InlineShape 被视为字母。 因此,采用相同的技术。
InlineShape is treated as a letter. Hence, the same technique.
我的最终代码最终使用
ThisDocument.Paragraphs
来获取我需要的范围。 但 GSerg 为我指明了使用Range
将对象放置在需要的位置的正确方向。My final code ended up using
ThisDocument.Paragraphs
to get the range I needed. But GSerg pointed me in the right direction of using aRange
to get my object where it needed to be.