Using the Macro IDE

Team-Fly    

 
Visual Basic .NET Unleashed
By Paul Kimmel
Table of Contents
Chapter 4.  Macros and Visual Studio Extensibility

Using the Macro IDE

By now you are familiar with IDEs in general, so we will just take a quick tour of the Macros IDE to point out some highlights.

Tip

You can change keyboard mappings in the Macros IDE by selecting Tools, Options, Keyboard. Selecting the Visual Basic 6 keyboard mapping scheme will make keyboard mappings in the Macros IDE consistent with VB6 mappings.


You can start the Macros IDE from the VS .NET IDE by choosing Tools, Macros, Macros IDE. The Macros IDE is project-centric; by default projects are stored in C:\ My Documents\ Visual Studio Projects\ VSMacros. Every time you create a macro project, a new subfolder is created using the project name. By default the macro project name is the same as the namespace for the project and has a .vsmacros extension.

A moduleexported to a .vb fileis stored internally in the .vsmacros file. Subroutines in the module are the actual macros. By default EnvDTE is imported using Imports EnvDTE added automatically to the top of the modules in a macro project.

You can use the same VB and coding techniques in macro modules as you would use in application modules. You can import other namespaces from the CLR as well as COM components by choosing Projects, Add Reference, although COM components will need to use TLBIMP.EXE on the COM component you want to import. Macro projects consist of modules and classes, but not forms.

Macro Security

Macros are stored as text in modules. Because macros are not compiled when you distribute them, anyone can look at your macro source code. If you want to protect macro code, you will need to place the macro code into an add-in and compile and distribute the add-in. (Refer to the section "Creating Add-Ins" later in this chapter for more information.)

Macro code is secure to the extent that it does not run when you open the macro. You must explicitly run a macro after it is loaded. If there are EnvironmentEvents defined, for example, OnStartupComplete, you will be warned about loading macro projects that contain event-handling code. By default Disable Event Handling Code is checked (see Figure 4.7); if you leave this option checked, potentially harmful macros that are run based on event code will not be started in the event-handling procedure.

Figure 4.7. If a macro project has event-handling code defined, you are notified and can leave the Disable feature checked to prevent potentially harmful macros from running.

graphics/04fig07.jpg

As long as you leave the Disable option selected, no macro code will start when a macro project is loaded, allowing you to safely share macro projects.

Macro Sharing

Macro code can be shared in a binary format by providing other users with the .vsmacros file or as text by exporting the individual .vb modules, which are exported as plain text files.


Team-Fly    
Top
 


Visual BasicR. NET Unleashed
Visual BasicR. NET Unleashed
ISBN: N/A
EAN: N/A
Year: 2001
Pages: 222

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