![]() |
Shortcut in c#
Hi ,
I would like to know if it possible to catch a shotcut and trigger a procedure in a c# com addin? Does someone has an example of this? Thx Manu |
Shortcut in c#
Hi Manu, I still don't know where and how Excel stores shortcuts, but here's my way to launch a C# routine with a shortcut. Create a C# Class Library, i.e. COMSAMPLE.cs which looks like this: using System; using System.Runtime.InteropServices; namespace COMSAMPLE { /// <summary /// Summary description for Class1. /// </summary public class Class1 { public Class1() { } public string FileVersion() { return "C# COM Sample Version 1.0 by Me"; } } } Nothing more, nothing less. Make sure you set Register for COM Interop to True in the project properties and then compile. In Excel, start Macro Recorder, make Ctrl-Shift-K (or any other) the shortcut and click OK. Do nothing but just stop recording 'cos now we have our desired shortcut. Finally, in the recorded macro: Sub Macro2() Dim x, s As String Set x = CreateObject("COMSAMPLE.Class1") s = x.FileVersion MsgBox s Set x = Nothing End Sub schreef in bericht ps.com... Hi , I would like to know if it possible to catch a shotcut and trigger a procedure in a c# com addin? Does someone has an example of this? Thx Manu |
All times are GMT +1. The time now is 04:41 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com