View Single Post
 
Old 02-06-2012, 04:16 AM
tinfanide tinfanide is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default Set range for merged Word table cells?

Code:
Dim oWord As Word.Application
Set oWord = New Word.Application
Dim oDoc As Word.Document
Set oDoc = oWord.Documents.Add
oWord.Visible = True
oDoc.Activate


With oWord


Dim Table1 As Word.Table
Set Table1 = oDoc.Tables.Add(Range:=oDoc.ActiveWindow.Selection.Range, _
NumRows:=6, _
NumColumns:=3, _
DefaultTableBehavior:=wdWord8TableBehavior)

    With Table1

    .Rows.WrapAroundText = True

        .Borders(wdBorderTop).LineStyle = wdLineStyleSingle
        .Borders(wdBorderRight).LineStyle = wdLineStyleSingle
        .Borders(wdBorderBottom).LineStyle = wdLineStyleSingle
        .Borders(wdBorderLeft).LineStyle = wdLineStyleSingle
        .Borders(wdBorderHorizontal).LineStyle = wdLineStyleSingle
        .Borders(wdBorderVertical).LineStyle = wdLineStyleSingle


.Rows(1).Cells.Merge
.Rows(2).Cells.Merge
.Rows(3).Cells.Merge

.Cell(4, 2).Select
With oDoc.ActiveWindow.Selection
.MoveDown Unit:=wdLine, Count:=2, Extend:=wdExtend
.Cells.Merge

''' Here, how can I reference to this merged cells?
''' I mean 
''' Dim rng As Range
'''  Set rng = ???

.Text = "Merged Column Cells"

End With


    End With

End With
Please see the comments.
I have tried
Code:
Dim rng As Range
Set rng = ActiveDocument.Range(Start:=ActiveDocument.Tables(1).Cell(4,2).Range.Start,End:=ActiveDocument.Tables(1).Cell(6,2).Range.End)
But error...
Reply With Quote