Microsoft Word Keybindings

N

nectar

Hello;

I've create a Word Addin using Visual Studio 2003. My addin creates a
Toolbar & item and I would like to assign a shortcut to it. (E.g. F2)

Is there any way to do this?
 
P

Peter Huang

Hi

I am researching the issue, and I will update you with new information ASAP.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Peter Huang

Hi

Also,

<><><><><><><><><><><><><> A N N O U N C E M E N T <><><><><><><><><><><><>
As part of Microsoft's continuing effort to improve the managed newsgroup
experience, the post notification email service is migrating to a quicker
and more configurable system. The current Post Notification system will be
discontinued on 11/19/2004. To continue to receive post notification
emails please navigate to http://msdn.microsoft.com/newsgroups/managed/ and
configure your profile. Detailed directions are available at
http://msdn.microsoft.com/subscriptions/managednewsgroups/#notifications.



Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Peter Huang

Hi

Commonly the way to do this is by using the KeyBinding object.
Unfortunately, shortcuts cannot be assigned to custom command bars. You
could assign to a macro and have the macro call back into the addin.

Also you may try to take a look at the link below.
http://word.mvps.org/FAQs/Customization/AsgnCmdOrMacroToToolbar.htm

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Peter Huang

Hi,

Here goes the code snippet.
1. Modify the attribute of the Connect ,add the Hello test funtion, so that
the com client, i.e. the VBA can see the function by using COM interface.
[GuidAttribute("E661AF83-1B16-4983-A64C-5E5FEDC0C4FC"),
ProgId("WordAddin.Connect"),ClassInterface(ClassInterfaceType.AutoDual),ComV
isible(true)]
public class Connect : Object, Extensibility.IDTExtensibility2

public void OnConnection(object application,
Extensibility.ext_ConnectMode connectMode, object addInInst, ref
System.Array custom)
{
applicationObject = application;
addInInstance = addInInst;
((Microsoft.Office.Core.COMAddIn)addInInst).Object = this;
}
public void Hello(string str)
{
System.Windows.Forms.MessageBox.Show(str);
}

2. in the VBA editor(i.e. word visual basic editor add a reference to the
com addin's tlb file.

3. Now we can call the Hello in the word macro.
e.g.
Sub Test()
Dim o As Object
Set o = Application.COMAddIns.Item("WordAddin.Connect").Object
o.Hello "df"
End Sub

In this way, the macro test will call the method hello in the addin

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Peter Huang

Hi,

If you have any more concerns on it, please feel free to post here.


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
N

nectar

Thank you;

The C# sample works great.

Is there any wasy to do this using a VC++ ATL addin?
 
P

Peter Huang

Hi

I will research the issue and give you a reply ASAP.
Thanks.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Y

Yan-Hong Huang[MSFT]

Hello,

Sorry for the late response. Currently we are contacting our support team
to see how to transfer the code to ATL. We will get back here with more
information as soon as possible.

If you have any more concerns, please feel free to post here and we will
follow up.

Thanks very much for your understanding.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
-http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.as
p&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.
 
S

Scott L. Heim [MS]

Hi,

There is a "COMAddin.exe" file that can be downloaded and it proviodes
sample code (VC++) for creating an Office COM Add-in. The following
Knowledge Base article provides a link for this file:

SAMPLE: Comaddin.exe Office 2000 COM Add-In Written in Visual C++ (230689)
http://support.microsoft.com/default.aspx?scid=KB;EN-US;230689

This should provide the information you are looking for - please let us
know if you need anything else.

Thank you,

Scott L. Heim, MCSD
Microsoft Developer Support

Please post questions to the newsgroup; everyone benefits.
This posting is provided "AS IS" with no warranties, and confers no rights.
Sample code subject to http://www.microsoft.com/info/cpyright.htm
 
Y

Yan-Hong Huang[MSFT]

Hello,

Scott has worked out a sample on it. If you are still monitoring the issue,
could you please contact us through email and we will send sample to you.
You can reach me and Scott by removing online from our email addresses here.

Thanks very much.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
-http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.as
p&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.
 

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