Can Word start up with a custom tab active?

C

Cooz

Hi everyone,

I have made a custom tab in the Word 2007 ribbon, and I would like this to
be the active tab when Word starts.

Can this be done? If yes, what should the customization XML look like, and
what VBA code should I provide?

Thank you,
Cooz
 
G

Greg Maxey

I have a custome tab keytip ZZ. I use this in a standard VB project module:

Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal _
bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const KEYEVENTF_KEYUP = &H2
Private Const VK_MENU = &H12
Private Const VK_Z = &H5A

Public Sub MakeTabActive()
keybd_event VK_MENU, 0, 0, 0 'Press ALT
keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0 'Release ALT
keybd_event VK_Z, 0, 0, 0 'Press Z
keybd_event VK_Z, 0, 2, 0 'Release Z
keybd_event VK_Z, 0, 0, 0 'Press Z
keybd_event VK_Z, 0, 2, 0 'Release Z
keybd_event VK_MENU, 0, 0, 0 'Press ALT
keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0 'Release ALT
End Sub

Sub AutoNew()
PauseCode 1200
MakeTabActive
End Sub

Sub AutoOpen()
PauseCode 1200
MakeTabActive
End Sub

Public Sub PauseCode(ByVal lngPeriod As Long)
DoEvents
Sleep lngPeriod
End Sub
 
C

Cooz

Hi Greg,

Yep, that is one way. Another is
SendKeys "%(ZZ)"
which works fine on my machine. With all due respect - but aren't you
reinventing SendKeys with all these lines of code? I'm not too fond of
SendKeys - or other implementations of it - for all the obvious reasons, but
I suppose it will have to do in this case.

I have been reading your articles on ribbon customization lately. They are
great. My sincere compliments to you for them. Once I started experimenting
with the three Microsoft articles that you mention in the "it doesn't take
rocket science"-article, but they were somewhat too advanced for me at the
time. Not they make a lot more sense.

Thank you,
Cooz
 
G

Greg Maxey

Cooz,

It has been awhile since I tinkered with making a custom tab active, but I
seem to remember having some inconsistencies with SendKeys. Sometimes it
would work and other times it wouldn't. Actually I can't positively
remember now why I added the delay in the method that I did post. It seems
like there was an issue in the actual template.

Thanks for your comments on the Ribbon articles. Like you, I had a hard
time getting my head around the data in the MS articles at first.


Good luck.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top