Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Nov 2002
    Posts
    387
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    I have used the following code to disable short-cut keys via VB6 Code but the same code does not work in .NET (VSTO) .NET 3.5 SP1

    Excel.Application.OnKey "^{s}" ' Ctrl+S Save
    Excel.Application.OnKey "^{x}" ' Ctrl+X Cut
    Excel.Application.OnKey "^{c}" ' Ctrl+C Copy
    Excel.Application.OnKey "^{v}" ' Ctrl+V Paste
    Excel.Application.OnKey "%{F8}" ' Alt+F8 Macros...
    Excel.Application.OnKey "%{F11}" ' Alt+F11 VBE


    What is different? Oh note that OnKey does not appear via IntelliSense.

    Thank you

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts
    If you are doing this in an add-in, then:
    Code:
    Me.Application.OnKey("^{s}", "") ' Ctrl+S Save
    (note: your code was actually re-enabling the shortcut!)
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    3 Star Lounger
    Join Date
    Nov 2002
    Posts
    387
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post

    [quote name='rory' post='797689' date='13-Oct-2009 13:38']If you are doing this in an add-in, then:
    Code:
    Me.Application.OnKey("^{s}", "") ' Ctrl+S Save
    (note: your code was actually re-enabling the shortcut!)[/quote]


    Thank you Rory. Yea I did figure-out on my own that my sample code was enabling rather than disabling. I just had a blind spot about the need for it being inside () instead of quotes. The code compiled without error and no exceptions were thrown and I am using that as my excuse for being so blind .

    Thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •