Word Macro: Move Cursor Down a Row

Posted by Bryan on Super User See other posts from Super User or by Bryan
Published on 2011-03-01T15:17:18Z Indexed on 2011/03/01 15:27 UTC
Read the original article Hit count: 301

Filed under:
|
|

I have a macro which I've been using to merge two cells together in a word table, but what I want to do is to get the cursor to move down by one cell, so that I can repeatedly press the shortcut key to repeat the command over and over.

The macro code that I have (shamelessy copied and pasted from a web page), is as follows:

Sub MergeWithCellToRight()
'
' MergeWithCellToRight Macro
'
'
Dim oRng As Range
Dim oCell As Cell
Set oCell = Selection.Cells(1)
If oCell.ColumnIndex = Selection.Rows(1).Cells.Count Then
MsgBox "There is no cell to the right?", vbCritical, "Error"
Exit Sub
End If
Set oRng = oCell.Range
oRng.MoveEnd wdCell, 1
oRng.Cells.Merge
Selection.Collapse wdCollapseStart
End Sub

I've attempted to add the following line just before the 'End Sub' statement

Selection.MoveDown wdCell, 1

but this generates the error, Run-time error '4120' Bad Parameter whenever I execute the macro.

Can anyone tell me how to correct this or what I'm doing wrong?

© Super User or respective owner

Related posts about microsoft-word-2007

Related posts about macros