Excel Add-ins

  • Thread starter Thread starter WAYNE MAIURI
  • Start date Start date
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
 
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.
 
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.
 
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
 
Back
Top