Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2005

Tip: Looking for answers? Try searching our database.

accelerator key

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jim C. - 20 Apr 2005 20:21 GMT
Hi,

I'm using Word 2000 and have created a form that is used to replace the
built-in form to accept or reject changes in order to create an audit trail
upon accepting changes.    I'm trying to make my custom form function as
close as possible to the built-in version.  

In the built-in version, the Find Next button allows the user to press 'F'
to find the next revision.  When I create an accelerator for the
corresponding button on my form, it requires the user to press alt-F.   Why
would there be a difference in how these act?  Is there some way to assign an
accelerator so that it would require only that key be pressed, not alt-key,
or ctl-key?

If there is no way to change how the accelerator feature works, is there
some other way to work around this to achieve the same functionality?

Thanks!

Jim
Jay Freedman - 21 Apr 2005 16:33 GMT
> Hi,
>
[quoted text clipped - 17 lines]
>
> Jim

Hi Jim,

The difference occurs because the MS developers added special code to the
built-in form, and that isn't available to you through VBA. :-(

There isn't any way to alter the accelerator behavior, but you can add code
to pick up single keypresses. You'll have to provide a subroutine to look
for your one-key accelerator and "click" the appropriate button, like this:

Private Sub cmdForward_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
  Accelerate KeyAscii
End Sub

' add a similar _KeyPress routine for each control that can have focus

Private Sub Accelerate(ByVal KeyAscii As MSForms.ReturnInteger)
  Select Case KeyAscii
     Case Asc("b")
        cmdBack_Click
     Case Asc("f")
        cmdForward_Click
     Case Else
  End Select
End Sub

Signature

Regards,
Jay Freedman
Microsoft Word MVP          FAQ: http://word.mvps.org

Jim C. - 22 Apr 2005 13:58 GMT
Hi Jay,

Thanks for reply.  After I had posted my question I had come to a simiilar
solution that you offered, though I wasn't sure it was the optimal one.  It
also took me a little time to realize that the keyPress event had to be
associated with the controls themselvles, and not to the form.

Jim

> > Hi,
> >
[quoted text clipped - 42 lines]
>    End Select
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.