Está en la página 1de 3

Apuntes Programación

Excel VBA
PARTE VI: Código de interés (III). Trabajando con
controles especiales

Jose Ignacio González Gómez


Departamento de Economía Financiera y Contabilidad - Universidad de La Laguna
www.jggomez.eu

INDICE
1 Excel VBA - SendKeys Method ............................................................................................................... 1
1.1 Introducción ......................................................................................................................................... 1
1.2 Argumentos del método ................................................................................................................... 1
1.3 Principales combinaciones de teclado ........................................................................................ 1
2 Bibliografía..................................................................................................................................................... 2
www.jggomez.eu Página |1

1 Excel VBA - SendKeys Method


1.1 Introducción
Esto nos sirve para asignar teclas a través de código VBA con el método SendKeys y
entre otras utilidades asignar macros a botones para crear barras de navegación.

1.2 Argumentos del método


Para el argumento Keys , puede utilizar las teclas o combinaciones de teclas , tales
como :

 SendKeys "+ { F2 }" ... para Shift + F2


 SendKeys "%ie~... para Alt + I, E, Enter

Ejemplo:

Sub CommentAddOrEdit()
Dim cmt As Comment
Set cmt = ActiveCell.Comment
If cmt Is Nothing Then
ActiveCell.AddComment text:=""
End If
SendKeys "+{F2}"
End Sub
Que equivale a…

Posteriormente asignar a una macro y botón.

1.3 Principales combinaciones de teclado


Key Code
BACKSPACE {BACKSPACE} or {BS}
BREAK {BREAK}
CAPS LOCK {CAPSLOCK}
CLEAR {CLEAR}
DELETE or DEL {DELETE} or {DEL}
DOWN ARROW {DOWN}
END {END}
ENTER (numeric keypad) {ENTER}
ENTER ~ (tilde)
ESC {ESCAPE} or {ESC}
HELP {HELP}
HOME {HOME}
INS {INSERT}
LEFT ARROW {LEFT}
NUM LOCK {NUMLOCK}
PAGE DOWN {PGDN}
PAGE UP {PGUP}
RETURN {RETURN}
RIGHT ARROW {RIGHT}
www.jggomez.eu Página |2

SCROLL LOCK {SCROLLLOCK}


TAB {TAB}
UP ARROW {UP}
F1 through F15 {F1} through {F15}

La combinacion de teclas Ctrl, Shift y/o Alt preceder el carácter con los siguientes
códigos . Por ejemplo:

SendKeys "+{F2}" ...for Shift + F2

Key Code
SHIFT + (signo mas)
CTRL ^ (caret)
ALT % (signo porcentaje)

2 Bibliografía
http://www.contextures.com/excelvbasendkeys.html

También podría gustarte