Monday, February 29, 2016

Useful VBA code to switch between tabs on the ribbon in MS Word and Excel !!!

Switch between various tab is one the very useful activity for certain VBA automation. Which is different for excel and word VBA programming. I got trick to navigate tabs on MS-Word or MS-Excel ribbon programmatically.

Given below are code which will enable you to navigate tabs on Excel and Word ribbon using VBA code.

in MS-Word:

Sub Navigate_Tab_On_Ribbon()
' Author: Dreams24
' Written for VBA Tricks and tips blog
https://vbatricksntips.com


'Sendkey combination to select "Insert" tab in MS-Word

'Sendkey for "Alt" Button on Keyboard
SendKeys "%", True
'Sendkey for "N" Button on Keyboard
SendKeys "{N}", True


End Sub

Given below are few key combination to navigate tabs on Word ribbon using VBA code:

Home            : Alt + H
File               : Alt + F
Insert            : Alt + N
Page Layout : Alt + P
References    : Alt + S
Mailings        : Alt + M
Review          : Alt + R
View             : Alt + W

in MS-Excel:

Sub Navigate_Tab_On_Ribbon()
' Author: Dreams24
' Written for VBA Tricks and tips blog
https://vbatricksntips.com


'Sendkey combination to select "Data" tab in MS-Excel
'Sendkey for "Alt+A" Button combination on Keyboard
Application.SendKeys "%A%", True

End Sub

Given below are few key combination to navigate tabs on Excel ribbon using VBA code:

Home            : Alt + H
File               : Alt + F
Insert            : Alt + N
Page Layout : Alt + P
References    : Alt + S
Formulas       : Alt + M
Data              : Alt + A
Review          : Alt + R
View             : Alt + W
Developer     : Alt + L
Add-Ins         : Alt + X

No comments: