首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何检测具有(水平)合并单元格的Word表格?

问如何检测具有(水平)合并单元格的Word表格?
EN

Stack Overflow用户
提问于 2010-12-24 10:09:01
回答 2查看 7.7K关注 0票数 4

当Word表格包含水平合并的单元格时,通过aTable.Columns访问aTable.Columns.First或执行For Each将导致错误。

有没有一种方法可以确定表格是否包含水平合并的单元格而不会导致错误?

我读过Determine if a Word cell is merged,但这是关于检测特定Word表格单元格是否合并,而不是整个表格是否有任何合并的单元格。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-01-04 07:41:38

在this article中找到了对表对象上的统一属性的引用,如果表合并或拆分了单元格,则该引用将返回false。

虽然这并不表示单元格是水平合并还是垂直合并(或两者都合并),但这是一个开始,该属性回答了我的问题。

票数 3
EN

Stack Overflow用户

发布于 2016-07-07 19:31:00

是的,它就在那里。以下是如何检测垂直合并单元格的逻辑解释。水平合并的单元也可以检测到,但需要更多的编码。

代码语言:javascript
复制
            But, unfortunately, not by calling any WORD VBA method or accessing any property of cell or table. It's by applying successive steps.

            Step1:
            -> Detect Row Count and Column Count of the table

            Step2:
            -> Declare an string array with same dimension as table( Dim A$()). Fill each cell of the array with "<m>" string.

            Step3:
            -> Start from cell(1)
            -> Then move cell by cell(Cell.Next method)
            -> Get each cells RowIndex and ColumnIndex.
            -> Erase the content "<m>" from the array, referenced by this RowIndex and ColumnIndex(A(RowIndex,ColumnIndex)=""
            -> Repeat this step until Cell.Next ends.

            Step4:
            -> Now check each cell of the Array(A$()). Those cells have the"<m>" string, are merged. Merged with immediate top cell. 

            I've not placed any function or code block. Assume it'll be more easy.

            Thanks

            Shubhayan
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4523806

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档