在Word VBA中指定新内联形状的位置?

发布于 2024-07-06 18:38:18 字数 432 浏览 4 评论 0原文

我正在为我工​​作的公司开发一个文档“向导”。 它是一个 .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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

酸甜透明夹心 2024-07-13 18:38:18

InlineShape 被视为字母。 因此,采用相同的技术。

ThisDocument.Range(15).InlineShapes.AddPicture "1.gif"

InlineShape is treated as a letter. Hence, the same technique.

ThisDocument.Range(15).InlineShapes.AddPicture "1.gif"
人生戏 2024-07-13 18:38:18

我的最终代码最终使用 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 a Range to get my object where it needed to be.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文