Table Cells merging speedup

N

NOPIK

Can I speed up a cells merging?
I'm transferring a report from Excel into Word. It has a lot of
differently formatted rows. Preformatting (cells
allocation,text,borders, etc) went fast, but when I start merge cells
execution time become 4-10 times longer (I got about 7sec without
merged cells, and about 30 with them). I already get rid of variants
where possible, and ScreenUpdating is False (anyway, saves only 2-4
seconds for my case).
Here is the problem code:
tabl.Cell(actrow, mrgcolstart).Merge Mergeto:=tabl.Cell(actrow,
mrgcolend)


Where tabl - target word table, actrow - row number, mrgcolstart and
mrgcolend starting and ending merged columns from row parser.
 
M

macropod

Hi Nopik,

If automatic column widths are enabled for a table, the constant re-calculation of the column widths after any actual or implied
string manipulation will slow down the macro's execution. The impact can be significant with long tables. To avoid this, either set:
MyTable.AllowAutoFit = False
or:
MyTable.AutoFitBehavior wdAutoFitFixed
 
Top