Question
November 25, 2008 at 09:02 AM
yangado74

Word tables in VBA – how to merge certain cells

by yangado74 . Updated 17 years, 9 months ago

Hi all,

I’m creating a macro which is basically formatting data in Word. There is a table which needs some cells merged.
The first two merges work fine: it’s when the macro hits the third it doesn’t recognize the selections anymore. Has anyone ever encountered this before? An excerpt of the macro can be seen here:

‘ Merging the first line
ActiveDocument.Tables(Nummer).Rows(1).Select
Selection.Cells.Merge

‘ Merging revenues and the rest
ActiveDocument.Tables(Nummer).Cell(1, 1).Select
Selection.SetRange _
Start:=Selection.Tables(Nummer).Cell(3, 1).Range.Start, _
End:=Selection.Tables(Nummer).Cell(3, 4).Range.End
Selection.Cells.Merge

Selection.Tables(1).Select
ActiveDocument.Tables(Nummer).Cell(1, 1).Range.Select
Selection.SetRange _
Start:=Selection.Tables(Nummer).Cell(5, 1).Range.Start, _
End:=Selection.Tables(Nummer).Cell(5, 2).Range.End
Selection.Cells.Merge

The first two merges look fine: the other one doesn’t. Any help is very much appreciated!
Thanks,
Ariadne

This discussion is locked

All Comments