Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 29th, 2003, 03:14 PM
Registered User
 
Join Date: Oct 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Removing a shortcut key programmatically

Does anyone know how to do this programmatically. I have to write a procedure to prepare a very complex spreadsheet for release and I would like incorporate this into it.

 
Old June 16th, 2004, 10:20 PM
Authorized User
 
Join Date: Jun 2003
Posts: 54
Thanks: 2
Thanked 0 Times in 0 Posts
Default

When you get the answer, let me know. I know the Application Object has a MacroOptions property that deals with shortcuts. I know the Names Collection (or Name Object) refers to shortcuts dealing with Excel 4.0 macros (look up Names in the Object Browser). I suspect this is the way to set/remove an assignment, ie. setting a name's shortcut = "".

My problem is I need to find a way to enumerate all assignments so that I can figure WHICH ones to remove.

After spending an hour looking for this today, I am stumped.




--- Tom
 
Old June 20th, 2004, 11:20 PM
Authorized User
 
Join Date: Feb 2004
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi There
This was the way I did the trick.

Example:
Remove Ctrl c
In the workbook_open event I have the following.
Sub AssignKey()
    Application.OnKey "^c", "Dummy"
End Sub
So now Ctrl c will call the sub Dummy, which have to be placed in a normal module.

Sub Dummy()
'Do nothing "now Ctrl c is disabled"
End Sub

Then the following code should be placed in the Workbook_BeforeClose event.
Sub ResetShortcut()
    Application.OnKey "^c", ""
End Sub

Hope it helps.
Cheers
Karsten




 
Old June 20th, 2004, 11:45 PM
Authorized User
 
Join Date: Feb 2004
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Again
A smal typo. Here we go.

Then the following code should be placed in the Workbook_BeforeClose event.
Sub ResetShortcut()
    Application.OnKey "^c"
End Sub

NOT
Sub ResetShortcut()
    Application.OnKey "^c",""
End Sub






Similar Threads
Thread Thread Starter Forum Replies Last Post
Shortcut key to Expand all regions in C# willfindavid C# 2005 1 July 10th, 2008 03:23 AM
minimize and Maxmze Application Using ShortCut key senpark15 C# 2005 1 April 11th, 2008 12:59 AM
removing key press in a batch file anu_hbti Other Programming Languages 1 February 2nd, 2008 02:43 PM
<bean:message key="PNR.INPUT"/> key has null value warsha_14 Struts 1 November 13th, 2006 07:26 AM
TAB KEY working together KEY PRESS event thomaz C# 4 August 20th, 2006 02:47 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.