Determine if a Word cell is merged

前端 未结 3 1283
走了就别回头了
走了就别回头了 2021-01-22 11:38

I need to programmatically add and remove rows from a Word 2010 table. Unfortunately the header of the table contains merged cells, both horizontally and vertically merged. Th

相关标签:
3条回答
  • 2021-01-22 12:09

    When dealing with tables that might contain merged cells, you always have to start with CELL(1,1) and step through the cells using CELL.NEXT (Next is a property of the CELL object)

    If you do that, you can interrogate what row and column the "current" cell is. You +can not+ reference cells by row col directly in tables with merged cells or you'll get the error you mention.

    Then just continue through till NEXT returns nothing.

    0 讨论(0)
  • 2021-01-22 12:24

    You will have to put off merging until you have dealt with all of the records.

    Word doesn't work well with tables.

    I suggest you create an Excel Workbook, and link the Worksheet from your Excel Workbook to your Word Document. Excel deals best with tables.

    0 讨论(0)
  • 2021-01-22 12:28

    Well I ended up describing the layout of the table in the Table Properties / Alt Text / Decription area. And then reading that in the code to split the cells, delete rows and then remerged the cells. Crude but it works.

    0 讨论(0)
提交回复
热议问题