Re: Merging two cells into one by JGM
JGM
Tue Nov 04 09:59:47 CST 2003
Hi Steve,
Try this:
_______________________________________
Selection.Cells(1).Select
Selection.MoveDown Unit:=wdLine, Count:=1, _
Extend:=wdExtend
Selection.Cells.Merge
_______________________________________
or, if you want something more comprehensive,
try fooling around with this:
_______________________________________
Dim MyRange As Range
Dim MyRangeCheck As Range
If Not Selection.Information(wdWithInTable) Then
MsgBox "You must select a cell within a table."
Exit Sub
End If
If Not Selection.Tables(1).Rows.Count = _
Selection.Cells(1).RowIndex Then
Selection.Cells(1).Select
Set MyRange = Selection.Range
Selection.MoveDown Unit:=wdLine, Count:=1, _
Extend:=wdExtend
Set MyRangeCheck = Selection.Range
If MyRange = MyRangeCheck Then
MsgBox "This cell has already been merged."
Exit Sub
End If
Selection.Cells.Merge
Else
MsgBox "You cannot use this macro when a " _
& "cell in the last row is selected."
End If
_______________________________________
HTH
Cheers!
--
_______________________________________
Jean-Guy Marcil
jmarcil@sympatico.ca
"Steve Wylie" <stevewy@hotmail.com> a écrit dans le message de news:
0f4401c3a2d5$ef7e9550$a301280a@phx.gbl...
> I have a short macro that selects the current cell of a
> table, and the one below it, and merges them both into
> one cell:
>
> Selection.MoveDown Unit:=wdLine, Count:=1,
> Extend:=wdExtend
> Selection.Cells.Merge
>
> However this macro does not work when the current cell
> contains text of more than one line (because of
> the 'Unit:=wdLine' bit, presumably). Is there a
> parameter I can use instead of wdLine? It does not seem
> to accept wdParagraph or wdTableCell or anything like
> that...
>
> Steve Wylie
>