Word 2007 Vba - 通过宏转到占位符

发布于 2024-10-04 03:54:40 字数 247 浏览 0 评论 0原文

好的,所以当我为一些客户创建多个模板时,我一直在与 Microsoft 进行斗争。我的问题是,分散在文档周围的简单文本框占位符允许我按 TAB 键转到下一个占位符。很像 Visual Studio 中的 Tab 键顺序。但由于某些奇怪的原因,这不适用于富文本框占位符。我需要对一些文本框使用富文本,因为应该允许用户更改单个字符的格式。这对于简单的文本框来说是不可能的。

所以我在想,使用宏可以实现这一点吗?例如,如果选择文本框占位符并运行宏,是否转到下一个占位符?

Ok, So I'm constantly battling with Microsoft as I'm creating several templates for a few customers. My problem is this, simple textbox placeholders scattered all around a document allows me to press TAB to go to the next placeholder. Much like Tab order in Visual Studio. But for some strange reason, this doesn't work with rich textbox placeholders. And I need to use rich text for a few textboxes because the user should be allowed to alter the formatting of single characters. This is not possible with simple textboxes.

So I was thinking, could this be possible using macros? For example, if a textbox placeholder is selected and the macro is run, go to the next placeholder?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

别念他 2024-10-11 03:54:40

来访问 Shape/TextBox 对象

ThisDocument.Shapes.Item(index)

可以通过检查返回的 Shape 对象

theShape.Type = msoTextBox

,但是,Shape 对象将按照它们创建的顺序返回,而不是按照它们在页面/文档上的顺序返回。要找到“下一个”文本框,您可能必须遍历所有文本框并调查它们的位置(.Top、.Left 等),以便找到要移动到的正确文本框:

theNextShape.Select

The Shape/TextBox objects can be accessed through

ThisDocument.Shapes.Item(index)

and checking the returned Shape object for

theShape.Type = msoTextBox

However, the Shape objects will be returned in the order that they were created, not their order on the page/document. To find the 'next' TextBox, you are probably going to have to loop through all TextBoxes and investigate their location (.Top, .Left etc) in order to find the correct one to move to with:

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