Excel Add-ins

W

WAYNE MAIURI

Does anybody out there know how to create an xll file? I have some
code that I am running in the Worksheet_SelectionChange(ByVal Target As
Range) event handler, but I would like to make it an add-in so I can use
it on all my files when I open them.

Any help would be greatly appreciated
Thanks in Advance!
Wayne




*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
A

Aaron Queenan

If you want to handle COM events, you're probably better of writing a COM
add-in rather than a Excel 4 (XLL) add-in.

Using the Visual Studio .NET wizard, select File/New Project, Other
Projects, Extensibility Projects, Shared Add-in, and follow the wizard steps
to create the project.

The other way of making one is to create a simple COM object:

1. Add the following to stdafx.h. For VC++ 6.0, change
"progid:Excel.Workspace" to "C:\Path\Excel.exe".

// Microsoft Add-In Designer Object Library
#import "progid:MSAddnDr.AddInDesigner" auto_rename, auto_search

// Microsoft Excel 10.0 Object Library
#pragma warning(push)
#pragma warning(disable : 4192) // automatically excluding 'name'
while importing type library 'library'
#pragma warning(disable : 4298) // identifier in type library
'library' is already a macro; renaming to '__identifier'
#pragma warning(disable : 4337) // cross-referenced type library
'typelib1' in 'typelib2' is being automatically imported
#import "progid:Excel.Workspace" auto_rename, auto_search,
no_implementation
using Excel::IRtdServer;
#pragma warning(pop)

2. Add the following to the .rgs file. Replace 'Plugin.Progid' with your
simple objected progid.

HKLM
{
NoRemove Software
{
NoRemove Microsoft
{
NoRemove Office
{
NoRemove Excel
{
NoRemove AddIns
{
'Plugin.Progid'
{
val
Description = s 'My plug-in short name'
val
FriendlyName = s 'Description of my plug-in'
val
LoadBehavior = d 3
}
}
}
}
}
}
}

3. Add the following to your class inheritance. NOTE the __uuidof
(Excel::AppEvents) is NOT a typo, even though the Excel::IAppEvents is being
implemented. Visual C++ .NET 2003 (and possibly other versions) doesn't
understand the wierd stuff Office puts in its type library, such as
implementing the dispinterface for the events directly rather than
inheriting from the vtable interface.

public IDispatchImpl<Excel::IAppEvents,
&__uuidof(Excel::AppEvents), &__uuidof(Excel::__Excel),
/* wMajor = */ 1, /* wMinor = */ 4>,
public IDispatchImpl<AddInDesignerObjects::_IDTExtensibility2,
&__uuidof(AddInDesignerObjects::_IDTExtensibility2),
&__uuidof(AddInDesignerObjects::__AddInDesignerObjects),
/* wMajor = */ 1, /* wMinor = */ 0>

Note that COM add-ins require Excel 2000 or later.

Regards,
Aaron Queenan.
 
E

EZ Money

Addins have the extension .xla. You can simply Save As that type, then
Tools>Addins>Browse to locate the file. If it is checked in Tools>Addins, it
should be available to you.
 
K

Keith Willshaw

WAYNE MAIURI said:
Does anybody out there know how to create an xll file? I have some
code that I am running in the Worksheet_SelectionChange(ByVal Target As
Range) event handler, but I would like to make it an add-in so I can use
it on all my files when I open them.

Any help would be greatly appreciated
Thanks in Advance!
Wayne

Unless you are an expeirenced C++ programmer (and even if you are)
I wouldnt recommend using XLL add-ins for this.

It will be much simpler to migrate your code to a com add-in
with VB

Keith
 

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