The VSTA SDK samples and VAO include code for ‘Macros’ and ‘Addins’, but this is really nothing more than a conceptual difference created by the application's architecture. The SDK samples support a Macro Recorder, which allows the end user to create customizations (macros) without any programming. Your application may support one or both of these concepts. Any VSTA customization (including a macro) is authored in an addin project, creating an addin assembly.
1. Macros are typically a set of functions contained in one addin assembly ie:
ShapeAppAdvancedCSharpMacros.dll
This is the case in the SDK samples.
Some characteristic typical of macros: macros have no parameters, are recorded, are called from the host application.
Macros are a specific kind of customization that are usually close to the end-user experience.
For instance, a macro may be used to automate drawing a frame around a new document.
The SDK samples load one ‘hardwired’ addin from a specific path that contains all macros recorded by the application’s macro recorder
2. Microsoft has determined that ‘Addin’ is the generic term for .Net customizations, extending the functionality of an application. Addins can do most anything. As the Testcon sample shows, the addin may even contain the bulk of an application.
A set of Addins are typically a collection of assemblies; each one may serve a more complex purpose than a macro would serve.
In the samples, there is a path to the application addin folder where all the app addins folders with assemblies are loaded. But this is a completely arbitrary default -- an ISV may provide any number of places to discover and load addin assemblies.
string[] appAddInDirNames = System.IO.Directory.GetDirectories(this.appAddInPath);
foreach (string appAddInDirName in appAddInDirNames)
{
string appAddInShortName = String.Format("{0}.dll", System.IO.Path.GetFileName(appAddInDirName));
string appAddInFullName = System.IO.Path.Combine(appAddInDirName, appAddInShortName);
if (!System.IO.File.Exists(appAddInFullName))
continue;
etc…
}
Addins may or may not be ‘close’ to the end user. Addins may run in the background or in an administrative role. They may add new UI features to the application.
An application (or document, etc..) may load and run any number of addin assemblies, even simultaneously.
As an example, an addin may connect two applications together in a workflow automation customization, sharing a document and updating its status.
Posted
Mar 21 2007, 11:45 AM
by
Gary