Home > Samples > Update > June 2006
Custom Code Moves to Office 2007

[bio]

The following is the full text of an article published by Directions on Microsoft, an independent research firm focused exclusively on Microsoft strategy & technology. More samples of our content, as well as a list of upcoming articles and reports are also available.

Changes in Office 2007 could affect macros and other application code written for earlier versions of the Office suite. Many users and organizations have written custom code, using Microsoft programming interfaces for Office, to automate common tasks in Office applications and to integrate the suite with enterprise applications, such as customer relationship management (CRM) systems. Most of this code will work on Office 2007 without change, but some will require deployment or coding changes. Therefore, developers and administrators interested in the new suite will want to take some preliminary steps to mitigate possible problems before rolling Office 2007 out.

Macros, Other Extensions Supported

Office 2007 supports all the technologies that users and developers have used to extend Office with custom code.

Most important, Office 2007 can run macros embedded in existing Office documents and templates. The suite still includes the Visual Basic for Applications (VBA) programming language and development environment for macros, and it still supports the COM APIs (called object models) that enable macros to trigger functions and trap events in applications such as Outlook and Word. VBA will not be ported to 64-bit processors, but 32-bit builds of the suite will include VBA and run on 64-bit processors.

Backward compatibility for macros is critical because macros are so widely used. Macros save keystrokes by automating frequently used sequences of commands, and developers use macros to integrate Office with enterprise applications—for example, to extract customer data automatically from Outlook e-mails or to look up related information in CRM systems or to generate Excel spreadsheets from data extracted from enterprise resource planning (ERP) systems.

Office 2007 also supports other existing technologies used to extend Office, including the following:

  • COM add-ins—code libraries that extend Office with new menus and other user interface features
  • Smart Tags—software components that recognize data embedded in Office applications (e.g., customer numbers) and provide users with menus of actions to take (e.g., look up a customer record in a CRM system)
  • Task Panes—windows that appear inside an Office application and present custom forms and other application-specific features, supplementing standard menu choices
  • ActiveX controls—graphical features such as a calendar control for choosing dates that can be embedded in documents.

However, Office 2007 changes the user interface, security, and other features, and these changes could require tweaking of macros or other customizations in order to migrate them to Office 2007.

Some Extensions Less Prominent

Changes in the Office 2007 user interface could hide some existing macros from users.

Specifically, Office 2007 replaces most menus and toolbars, the basic building blocks of the Office user interface in previous versions, with a tabbed ribbon of command buttons. Consequently, custom menus and toolbars created by extensions have no natural place to land. Instead, these features will end up in an "Add-Ins" tab of the new Office 2007 user interface. (See the illustration "Office 2007 Add-Ins Tab".) As a result, users moving to Office 2007 might have a hard time finding and using an extension, even though the extension might work perfectly once found.

Some workarounds limit the impact of the change. Most important, Office 2007 will preserve Office 2003 keyboard shortcuts and menu accelerators (key sequences beginning with Alt that trigger menu commands). Menu accelerators were not supported in Office 2007 Beta 1 builds, but will be supported in the production release. So macros and other extensions triggered from the keyboard will work without change in Office 2007. Also, Office 2007 provides a permanent Quick Access toolbar where users can park buttons for commands, including macros and extensions, that they use frequently.

If developers want existing extensions to appear more prominently, they will need to create an Office 2007 RibbonX extension that encompasses their existing code. RibbonX extensions integrate commands directly into the Office 2007 ribbon or file menu and can call existing macros or other extension code. However, design tools for RibbonX extensions will not ship with Office 2007; they will probably appear in the next version of Visual Studio Tools for Office (code-named VSTOv3), which is not due until late 2007, with the next major Visual Studio release.

File Format, Security Settings Could Block Code

Because Office 2007, like its predecessors, can run code, it is vulnerable to attacks by malicious code, such as macro viruses. However, Microsoft has taken some steps to tighten the suite's defenses, which could affect some existing Office extensions.

Macros Excluded from Files

Documents saved in Office 2007's default format cannot contain macros. This measure makes Office 2007 less susceptible to macro viruses carried in documents, but it could also affect existing macros that organizations have deployed by distributing documents.

However, there are several loopholes:

Other file formats. Office 2007 can load, create, and save documents in earlier Office file formats, and those formats can include macros. Office 2007 also includes variants of its own native file formats that can store macros. Office 2007 will not use these macro-enabled formats by default, but users can choose them, and administrators can make them the default through Group Policy.

Templates and add-ins. Office 2007 can still run macros stored in Office document templates, such as Word's default normal.dot template. Office 2007 can also run other kinds of extensions (such as COM add-ins) installed as applications on a machine. So organizations can get around the restrictions on Office 2007 document formats by deploying macros in template files and installing other kinds of extensions on computers.

Excel More Choosy About Code

Like Office 2003, Office 2007 will disable execution of most unsigned code by default. Normally, when this occurs, users will see a new Document Alert Bar that lets them enable macros selectively. From the Document Alert Bar, users can also jump to Office 2007's Trust Center, a new dialog box for managing application security settings. (See the illustration "Trust Center and Document Alert Bar".)

Developers should note that Excel 2007 has tighter code security than Excel 2003 did: Excel 2007 will disable all macros in a document rather than prompting the user for permission to run them, as in earlier versions, and will also disable ActiveX controls in documents. This puts Excel 2007 in line with the other Office 2007 applications, which by default will block code and display the Document Alert Bar.

As a result, some existing Excel macros and solutions that use ActiveX controls could require more user intervention than with earlier versions of Excel, a potential irritant for users. However, administrators can prevent such inconveniences by signing code or loosening Excel 2007 code security selectively for specific groups and users through Group Policy.

In general, most organizations will want to adjust Office 2007 security settings through Group Policy rather than relying on users to work with the Trust Center. Group Policy can be centrally controlled, and it doesn't force users to make difficult decisions about which documents and code to trust.

Minor Object Model and Developer Changes

Office 2007 preserves most of the existing COM APIs (object models), which enable macros and other extensions to use application features, such as inserting a paragraph in Word or loading data into an Excel chart. However, some object model changes could break some extensions, and some developer-oriented features have been removed. The most notable changes include the following:

Charting. The object model of Excel 2007's charting feature has changed enough to affect some extensions that build Excel charts automatically. Also, embedded charts in Word and PowerPoint 2007 are Excel charts rather than Microsoft Graph charts, and they do not support the Microsoft Graph object model. As a result, Word or PowerPoint extensions that work with user-inserted charts might fail. Note that the Graph object model still works and code can still insert Graph charts in Word and PowerPoint 2007 documents. However, charts inserted by Office 2007 users will all use the Excel charting object model, and Microsoft recommends moving code off the Graph object model where possible.

Excel statistical and engineering functions. Excel 2007 incorporates a set of statistical and engineering functions that were formerly part of the Analysis ToolPak, an add-in. Because of this change, the functions are located in a different place in the Excel object model, and extensions that use the functions must be rewritten to call the functions from their new locations.

Web controls and design features eliminated. Office 2007 will ship without the Office Web Components, ActiveX controls that support data access, spreadsheets, charting, and PivotTable analysis in Internet Explorer. This means existing Web pages that use the controls will not work on Office 2007 systems, unless users or administrators separately download and install the controls (which will still be available from Microsoft). Web page design features that require the controls have been removed from Office 2007; these include Excel's Save As Web Page "Add interactivity" option, and the Access Data Access Pages design feature. (See "Office 2007 Retires Web Controls".)

Developers updating or writing new Outlook extensions will want to investigate the expanded Outlook 2007 object model, which eliminates the need for many Outlook extension APIs. (See the sidebar "Outlook 2007 Consolidates APIs".)

Review Code, Policies

Overall, Office 2007 preserves more than it changes in application development. Nevertheless, organizations that are evaluating Office 2007 for purchase, or as a component of IT solutions, should take early steps to address the key changes:

Developers. Developers should evaluate the user interfaces of macros, COM add-ins, and other extensions and determine whether they will move forward smoothly to Office 2007. Developers should also review their extensions against the "deprecated feature" documentation in the Office 2007 beta releases; extensions for charting and for mathematical or statistical analysis should get particular scrutiny, because those extensions could be affected by the changes to charting and Excel object models.

Administrators. Administrators should have (or build) an inventory of the extensions used in their organization and how they are deployed. Macros and ActiveX controls in Excel and macros distributed in Office documents require particular scrutiny, because these will be affected by Office 2007 default security settings and file formats. Microsoft intends to release a scanning tool (called the Office Migration Planning Manager) to help organizations locate Office macros and other extensions in their networks, but existing software distribution products (such as Systems Management Server) could be invaluable as well.

Resources

Office 2007 user interface changes are outlined in "Office 12: New User Interface, Content Management" on page 23 of the Oct. 2005 Update.

New file formats for Office 2007 are discussed in "Office 12: New File Format" on page 27 of the July 2005 Update.

The Visual Studio Tools for Office 2005 and other Office development platforms are outlined in "Office Document Processing Platform Emerging" on page 23 of the July 2005 Update and "Visual Studio Tools Add Outlook Support" on page 16 of the Sept. 2005 Update.

Microsoft's site for Office developers is msdn.microsoft.com/office.

The preview site for Office 2007 is www.microsoft.com/office/preview.