Wednesday, June 06, 2012

Run time error 5992

The other day I stumbled on this error in Word 2007
Run time error 5992 'Cannot access individual columns in this collection because the table has mixed cell widths.'
I was working on BeyondCompare to generate HTML file difference reports and paste this to Word. BeyondCompare report uses tables and it had a few rows that spanned across multiple columns. This was causing problems for Word VBA. I looked for solutions on the web, but unfortunately could not find any. It seemed silly because the individual columns can be moved manually using the margins on the ruler, but the script cannot access it. It became clear that this is limitation of Word VBA interface and I need to look for work arounds.

I edited the HTML to remove offending spans and pasted the tables to Word and this error is gone.

Another solution is to probably to use script to remove the spans in Word itself or work on the individual cells adjusting its width.

No comments: