newbie: office 2003 and VS.NET

D

Dan

Hi all, I'm new to Office 2003 addins and VS.NET tools for it. I have Visual
Studio .NET 2003, Visual Studio office tools, Office 2003 Pro, and I'd want
to develop some Word 2003 addins. I'd like to ask a couple of beginner
questions:

1) I'd like to develop a C# DLL which exposes some functions which can be
called from Word VBA. In old C++ days I did it creating a COM DLL and adding
a reference to it from the VBA project; now I'd want to use C#. In .NET how
this is supposed to be done?

2) I'd like to trigger the call to some of these DLL functions in Word
itself when pressing a specified keyboard shortcut: in previous versions of
Office I think this could not be done, so that I resorted using a DOT VBA
template with predefined keyboard bindings which called the DLL functions.
This means I had to sacrifice the ad-hoc addin architecture, which could add
toolbars but could not be bound to specified keyboard shortcuts
programmatically.

With reference to these questions, how does the new .NET addin architecture
fit in the whole picture (which project to use, which limitations to
consider, etc...)?

Thanks to all!
 
W

Wei-Dong Xu [MSFT]

Hi Dan,

Thank you for posing in MSDN managed newsgroup!

If you want to call the .Net component from VBA, this is just an issue for calling .Net componet from com. There is one MSDN article which
introduces much information for you on this issue. Please go to:
Calling a .NET Component from a COM Component
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/callnetfrcom.asp
The usage for .Net component in VBA is the same to the one for com component. You can simply select it in the Tools->Reference... and pick up the
dll you want to use the function .Net component provides.

For handling word event with .Net, I'd suggest two kb articles will help you a lot on how to handle word event by using Visual C#.net. Please go to
302817 HOWTO: Handle Events for Word by Using Visual C# .NET
http://support.microsoft.com/?id=302817

302295 HOWTO: Obtain the Window Handle for an Office Automation Server by Using
http://support.microsoft.com/?id=302295

Please feel free to let me know if you have any further questions.

Does this answer your question? Thank you for using Microsoft NewsGroup!

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

Dan

Many thanks, the articles you cited are very useful! Now it's clear how to
create a COM-callable .NET component; as for Word events, I grab the general
picture, but still I can't figure how I could create an addin which not only
handles the Word "standard" events (open document, close document, button
click on a custom toolbar, etc.), but also to some predefined key
combinations. For instance, I'd like Word to call my addin functions not
only when a button is pressed in its toolbar, but also when e.g. user
presses Ctrl+Q. How could this be done?

Anyway, thanks again you for your help!
 
W

Wei-Dong Xu [MSFT]

Hi Dan,

Thank you for replying!

If you want to give a response to self-defined quick key(for example Ctrl+Q), so far as I know, you should use windows Hook to get the input and
then call the related function or method of your .Net add-in. You can obtain more information about windows hook from MSDN.Microsoft.com. Please
go to:
Win32 Hooks
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwui/html/msdn_hooks32.asp
Hooks (MSDN reference for Hook)
http://msdn.microsoft.com/library/e...suserinterface/windowing/hooks.asp?frame=true

Since you are going to build the add-in in C#, there is one MSDN magazine article from Dino Esposito will introduce the usage of Hook in .Net world.
Please go to:
Windows Hooks in the .NET Framework
http://msdn.microsoft.com/msdnmag/issues/02/10/CuttingEdge/

Please feel free to let me know if you have any further questions.

Does this answer your question? Thank you for using Microsoft NewsGroup!

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
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