Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2006

Tip: Looking for answers? Try searching our database.

Error 5991 - "table has vertically merged cells" - How can I unmer

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Maxer - 11 Apr 2006 17:17 GMT
I have VBA code in word that is going to each table in the word document,
then doing some testing, then moving to each row in the word document, then
finally to each cell.

Once it finishes its tests it moves them over into an Excel worksheet.

Now the process works perfectly for my needs, until I hit a table that has
vertically merged cells.

At my:
------
Set oRows = oTable.Rows
For Each oRow in oRows
'do stuff'
Next oRow
-----
part of the code as soon as it gets to "For Each oRow in oRows" then it
throws up the 5991 error:

Run-time error '5991':
Cannot access individual rows in this collection because the table has
vertically merged cells.

I badly need some way to programmatically split those merged cells.

I actually don't even want those merged cells, they are just the first part
of several tables in the word document.  I don't really start moving any data
around until I get a few rows into the table (though the row number varies
table by table).

Anyway, does anyone know of a way I can either test for vertically merged
cells and then just skip to the "Next oRow" or if I can't do that then split
them so that it doesn't stop my code from completing it's processing?

Sadly I can't unmerge them by hand as there are thousands of tables in this
word document and a hundred or so have these merged cells.

Thank you for your help.
Jean-Guy Marcil - 11 Apr 2006 20:35 GMT
Maxer was telling us:
Maxer nous racontait que :

> I have VBA code in word that is going to each table in the word
> document, then doing some testing, then moving to each row in the
[quoted text clipped - 35 lines]
>
> Thank you for your help.

If you use a Range object, you can access all the cells, even if they are
merged:

Dim oTableRge As Range
Dim oCell As Cell

Set oTableRge = ActiveDocument.Tables(1).Range

For Each oCell In oTableRge.Cells
   MsgBox oCell.Range.Text
Next

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 


Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.