Sharing Macros with Others


If you want to share the macros that you've created, you have a number of choices to make. Do you want to share the source? Do you want to share the whole project or just part of it? The answers to these questions will determine how to best share your work. Let's take a look at the different ways that you can share your macro functionality with others.

Exporting Modules and Projects

The easiest way to share your macros with other developers is to simply cut and paste your source code into e-mail messages and Usenet postings. This approach works well if the methods you're sharing are fairly short and if they don't span multiple modules. If they do span multiple modules, you'll probably want to export the modules you want to share or simply pass on the whole project.

To export a macro module in Visual Studio, you must open the Macros IDE and select the module you want to export from the Project Explorer window. Pressing Ctrl+E will invoke the File.SaveSelectedItemsAs command, which brings up the Export File dialog box. This command is listed on the File menu as the Export (module name) command.

The Export File dialog box lets you save the module as a .vb file that you can easily import into another project by using the File.AddExistingItem command (Shift+Alt+A). Don't forget to include the code from the EnvironmentEvents module if your macros rely on some sort of event functionality.

If your macros are very complicated, you might want to share an entire macro project. You can do this in a couple of ways. You can copy the .vsmacros file for the project and pass it along, or you can save your macro project as a text-based project and share those files.

To make a macros project text-based, change the StorageFormat property in the Visual Studio IDE for the project that you want to change. Select the project in Macro Explorer and then change the StorageFormat property in the Properties window from Binary (.vsmacros) to Text (Unicode). This change will create a number of files in the macro project's folder, which looks much like a regular Visual Studio project folder. In Figure 5-9, you can see the folder for the Samples project after it has been converted to Text format.

image from book
Figure 5-9: A macro project that has been stored in Text format

The advantage of passing along a text-based project is that it allows other programmers to look at the source files in your project before loading them into their IDEs.

There's always a security risk in opening unknown macro projects in any application. Be sure you know where any binaries you open come from. At the very least, check the EnvironmentEvents.vb module to make sure it doesn't include any unexpected code.




Working with Microsoft Visual Studio 2005
Working with Microsoft Visual Studio 2005
ISBN: 0735623155
EAN: 2147483647
Year: 2006
Pages: 100

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net