使用 VBA 确定 Word 中表格的列数
只是一个简单的问题。 我在 Word 模板中得到了这个表格,默认情况下有两列。 然后我有一个按钮,如果用户想要另一列,可以按下该按钮。宏运行会插入几个文本占位符并自动设置某些内容的格式。 但我想要的是某种例程,它基本上检查此表中的列数,如果有两列,则输入的文本自动为“第 3 列”,如果有三列,则文本应为“第 4 栏”。如果我能找出如何找到列数,那应该很简单。
just a quick question.
I've got this table in a Word template which have two columns by default.
Then I've got this button the user can press if he wants another column. The macro run inserts several text placeholders and formats certain things automatically.
But what I want is some sort of routine which basically checks the number of columns in this table, and if there are two columns, the text typed in is automatically "Column 3" and if there are three columns there, the text should be "Column 4". Should be pretty simple if I can just find out how I can find the number of columns.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
表对象知道它有多少列,只需检查 Columns.Count 属性即可。
A table object knows how many columns it has, just check the Columns.Count property.
这有效:
This works: