I’m trying to create a certain keyboard macro (using the Record Macro function on the button on the ribbon in Word 2010), a macro that transposes the two typed characters to the right of the cursor.
(I make a lot of typing errors like that.) Thus, if I mistakenly type the list of numbers 12435, and then place the cursor before the “4”, the macro would transpose the “4” and the “3” so that my list would then be in the correct order.
Using keyboard strokes, I would do this manually as follows:
- Press Shift and hold it down, tap the right arrow key, release both.
(This selects the “4”.)
- Tap the F2 key. (This activates “Move to Where?”)
- Tap the right arrow key twice. (This tells it I want to move the selection (the “4”) two characters to the right, which would place it after the “3”.)
- Tap “Enter”. (This completes the “move”.)
- Tap the left arrow key twice. (This tells it I want to move the cursor two characters to the left, which would put it back where it started, which is where I want to be to continue typing.)
When I try to record this keystroke sequence, something is not taking.
I am able to record a simple macro, for example, typing a single letter.
That works. But I can’t record this one. Somewhere in the F2 area it seems to stop working.
What’s up? Are there certain keystrokes that the “Record Macro” function won’t take? FYI, it shows the following when I "view" the macro after I record it and it doesn't work. In this case, I named it "b" and gave it the Alt-B keyboard shortcut.
b b()
'
' b Macro
'
'
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.MoveLeft Unit:=wdCharacter, Count:=2
End Sub