Chapter 9. OLE, Mail Merge, and Office Applications


ADMINISTERING MACROS

Move a Macro from One Template to Another

The Annoyance:

I reckon I've more or less gotten the hang of the Visual Basic Editor by nowat least, I can create and edit macros in different projects. But do you mean to tell me that I need to use Cut and Paste to move a macro from one project to another?

The Fix:

You've hit upon one of the Visual Basic Editor's most dramatic shortcomings: the inability to copy or move a macro quickly from one project (a template or document) to another. But Word itself can take care of this task: choose Tools Macro Macros, click the Organizer button in the Macros dialog box, and then click the Macro Project Items tab. See which projects are open in the two "Macro Project Items available in boxes; if necessary, click the Close File button to close one of the open projects, and then use the resulting Open File button to open the relevant project. With the projects open , select the item you want to copy, and click the Copy button. To move an item, copy it to the new location and then click the Delete button to delete it from the source project.

When you've finished copying or moving items, click the Close button to close the Organizer dialog box, and save the documents or templates with which you've been working.

Find Out Why Word Won't Run a Macro

The Annoyance:

When I open the template that one of my colleagues has developed, Word says that the macros are disabled and tells me to check the host application's online help or documentation. Help! What's a host application, what's the problem, andmost of allhow do I fix it?

The Fix:

Visual Basic for Applications is what's called a hosted programming language: instead of running on its own, as Visual Basic itself does, VBA requires a host application to provide it with an environment in which to work. Word is the host application here; the other Office applications, and many other applications, also host VBA.

The problem is that Word's security settings are set to protect you from potentially dangerous code. Because VBA can take a wide variety of actions on your computer without your intervention, it's a security threat. Consequently, Microsoft has bundled up Word (and the other Office applications) increasingly tightly against malefaction. When you open a VBA project that might be dangerous, Word disables its macros (see Figure 8-5).

Figure 8-5. If Word automatically disables macros that you need to run, you may need to change your security settings.

To change the security settings so that you can run the macros ( assuming that you trust the template's creator not to use them to wreak havoc on your machine), choose Tools Macro Security and select the appropriate option on the Security Level tab (see Figure 8-6). Word 2003 offers Very High, High, Medium, and Low levels; Word XP and Word 2000 do not offer the Very High level. Heres what you need to know about the details:


Trusted locations

By default, Word trusts macros in templates and add-ins (for example, global templates) installed on your computer. So, even if you set the security level to Very High or High, you can still run any macros that you create yourself. To prevent Word from trusting installed templates and add-ins, uncheck the "Trust all installed add-ins and templates" box on the Trusted Publishers tab (Trusted Sources tab in Word XP and Word 2000).

Figure 8-6. The Security Level tab lets you control whether Word will run macros that are not signed with digital signatures or installed in trusted locations.


Trusted publishers/trusted sources

Trusted publishers (in Word 2003), also known as trusted sources (in Word XP or Word 2000), are people or entities for whom a digital certificate is installed on your computer and who are designated as trustworthy. You can view the list on the Trusted Publishers tab or Trusted Sources tab. If you administer your computer, you will probably be able to add trusted publishers or sources; if so, Word will prompt you when you open a document, template, or add-in that has been signed by a digital certificate that's not yet trusted. In a corporate network, network administrators usually manage trusted sources.


Tip: A digital certificate is encrypted code that uniquely identifies its holder. Digital certificates are available from certification authorities (CAs) such as VeriSign (http://www.verisign.com), Thawte (http://www.thawte.com; a VeriSign company), and GlobalSign NV (http://www.globalsign.com). Some companies also issue digital certificates to their own staff from in-house CAs.

Signed and unsigned macros

A signed macro is one that has been digitally signed by the holder of a digital certificate. Being signed doesn't mean that the macro is necessary benevolent or trustworthy, just that it has some form of audit trail attached to it. Similarly, being unsigned doesn't necessarily mean that a macro is malicious.


Tip: If you distribute your macros to other people, you will need to sign them to ensure that they are trusted. Once you've installed a digital certificate on your PC, you can sign a macro project (for example, a template) in the Visual Basic Editor: click the project in the Project Explorer, choose Tools Digital Signature, click the Choose button, pick the certificate in the Select Certificate dialog box, and click the OK button to close each dialog box.
Macro Macros, and click the Organizer button. Use the controls on the Organizer dialog boxs four tabs to move the AutoText entries, keyboard shortcuts, and custom toolbars and menus to the new template. Save the template and close it.

Still in Word, choose Tools Templates and Add-Ins, click the Add button, navigate to and select the template, and then click the OK button to load it as a global template. Back up this global template frequently as well, in case it too sustains corruption.


Tip: You can load the global template automatically, if you prefer, by placing it in your Word Startup folder. Choose Start Run, type %userprofile%\Application Data\Microsoft\Word\Startup , and press Enter to open a Windows Explorer window to your Word Startup folder.


Word Annoyances
Word Annoyances: How to Fix the Most ANNOYING Things about Your Favorite Word Processor
ISBN: 0596009542
EAN: 2147483647
Year: 2003
Pages: 91

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