Select a all tables within table using Word Macro

走远了吗. 提交于 2020-01-17 07:25:35

问题


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?


回答1:


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. :)



来源:https://stackoverflow.com/questions/11981981/select-a-all-tables-within-table-using-word-macro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!