问题
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