30.04.2017 Views

4523756273

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

352<br />

Part V: Putting It All Together<br />

When you open an add-in, you may or may not notice anything different. In<br />

many cases, however, the Ribbon changes in some way — Excel displays<br />

either a new tab or one or more new groups on an existing tab. For example,<br />

opening the Analysis ToolPak add-in gives you a new item on the Data tab:<br />

Analysis➪Data Analysis. If the add-in contains only custom worksheet functions,<br />

the new functions appear in the Insert Function dialog box, and you’ll<br />

see no change to Excel’s user interface.<br />

Add-In Basics<br />

Although you can convert any workbook to an add-in, not all workbooks benefit<br />

from this conversion. A workbook with no macros makes a completely<br />

useless add-in. In fact, the only types of workbooks that benefit from being<br />

converted to an add-in are those with macros. For example, a workbook that<br />

consists of general-purpose macros (Sub and Function procedures) makes an<br />

ideal add-in.<br />

Creating an add-in isn’t difficult, but it does require a bit of extra work. Use<br />

the following steps to create an add-in from a normal workbook file:<br />

1. Develop your application and make sure that everything works<br />

properly.<br />

Don’t forget to include a method for executing the macro or macros.<br />

You might want to define a shortcut key or customize the user interface<br />

in some way (see Chapter 19). If the add-in consists only of functions,<br />

there’s no need to include a method to execute them because they will<br />

appear in the Insert Function dialog box.<br />

2. Test the application by executing it when a different workbook is<br />

active.<br />

Doing so simulates the application’s behavior when it’s used as an<br />

add-in because an add-in is never the active workbook.<br />

3. Activate the VBE and select the workbook in the Project window;<br />

choose Tools➪VBAProject Properties and click the Protection tab;<br />

select the Lock Project for Viewing check box and enter a password<br />

(twice); click OK.<br />

This step is necessary only if you want to prevent others from viewing<br />

or modifying your macros or UserForms.<br />

4. In Excel 2010, choose Developer➪Document Panel. In Excel 2007,<br />

choose Office➪Prepare➪Properties.<br />

Excel displays its Document Properties pane below the Ribbon.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!