使用Word宏选择表中的所有表 [英] Select a all tables within table using Word Macro

查看:143
本文介绍了使用Word宏选择表中的所有表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我定期得到这些文件,这些文件必须进行格式化,并且所有数据都存储在较大的表内的表中,以用于布局目的.

I have these documents that I get regularly that I have to format and all the data is stored within tables that reside inside larger tables for layout purposes.

如果可以使用宏,我想在表格中设置表格的列宽样式吗?

I'd like to style the column widths of the tables within tables if it's possible with a macro?

推荐答案

您可以直接引用嵌套表.使用以下命令,您可以获取文档中第一个表中包含的表数.

You can reference the nested tables directly. With the following command you get the number of tables contained in the first table in the document.

Debug.Print ThisDocument.Tables(1).Tables.Count

然后您可以遍历它们并根据需要对其进行格式化:

You can then loop through them and format them as desired:

Dim oTable as Table

For Each oTable in ThisDocument.Tables(1).Tables

    'Do something with oTable - like
    'setting the width of the first column
    oTable.Columns(1).Width = 60

Next

别忘了先检查文档中是否有表格. :)

Don't forget to check to see that there are tables in the document first. :)

这篇关于使用Word宏选择表中的所有表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆