Continuing with the deep dive into new tools in Office 2010 Application Compatibility, we would like to explore and illustrate in detail how Code Compatibility Inspector (CI) functions.
The Microsoft Office 2010 Code Compatibility Inspector is designed to assist an enterprise or small business with updating VBA and VSTO code so that it becomes compatible with Office 2010. While the tool does not directly make code corrections (other than correcting Declare Statements for 64bit compatibility in VBA), it does comment code in locations where potential Object Model changes have been identified. Users or developers debugging their code can get assistance from the comments and links to topics on MSDN that detail the changes that may be affecting a specific line of code. Here is what CI actually do:
- The Code Compatibility Inspector consists of four addins that load in PowerPoint 2010, Word 2010, Excel 2010 and Visual Studio (VS 2008 is the targeted version with VB.NET and C# languages supported).
- It operates on a per-user/per-document/per-solution basis. When a user opens a document (or Visual Studio solution) they can run the tool from the developer tab (or Tools menu in Visual Studio).
- The CI scans the VBA projects in the current document or Visual Studio Solution via simple text search looking for parentObject.Property combinations.
- It also scans Declare statements for 64bit compatibility in VBA.
- Where potential issues are found, the tool will add comments right next to that code, including links to the topics on the details of the change pointing to MSDN.
- When completed, the tool will provide a summary and detailed report of what was found in the project as well as an option to remove the inserted comments.
CI can be run by an individual developer or macro user, when they have access to the code. Here is what you can expect to see when you download and run the installation package:
You have choice of the installation either in the Office VBA environment or in the Visual Studio environment or both if you prefer.
To inspect a code in a document for compatibility, you would follow these steps:
- Open the desired document in PowerPoint/Word/Excel.
On the Developer Tab, click Inspect VBA Code.
- On the Inspect VBA Project dialog, select the options you want, then click Inspect.
- The Inspect Visual Basic for Application Projects has to be checked in order to inspect your VBA project for potential Object Model changes.
The Inspect Declare Statements will make your project 64bit compatible. Select this option if:
- Your project will only be run on Office 2010.
- May be run on a system running 64bit Office 2010.
- The Add comments option will place comments in your code where potential compatibility issues are discovered. These comments will appear similar to the following:
The <URL></URL> tag will contain a URL to the relevant site on MSDN describing the suspect OM change found (it is not in this picture because.
The Detailed Report option will create a text file report at the end of the inspection process. This report will contain the following information:
Document scanned: c:\Test.ppt
Date scanned: Tuesday, October 20, 2009
Total lines scanned: 319
Total items found: 35
Deprecated items: 0
Changed items: 2
Redesigned items: 0
Declare statements: 32
CODE: Set objMaster = ActivePresentation.SlideMaster
CODE: Set objMaster = ActivePresentation.TitleMaster
- When the scan is completed, you will get a summary report similar to the following that will detail the number of changed items, deprecated items and design changed items (described in more detail below):
- Total Lines Scanned – the total number of VBA code lines scanned in the document.
- Total items found – this is the total number of declare statements updates, changed items, deprecated item and design change items found in the code.
- Deprecated items – these are items that were found which were removed from the object model. These items may require a code workaround – an alternative approach as the feature it is dependent on is no longer available in the product.
- Changed items – these are the items found where the syntax of the command were changed and may need to be updated.
- Redesigned items – these are items where the syntax is still the same and the item/feature still exists. However, the desired result may no longer be the same. For example, a textbox formatting may have changed because of new text services. While a textbox will be created, the layout of the text in the box may differ when compared to previous versions.
- Declare statements – this is the count of the total number of Windows API statements that were detected in the VBA code and were updated for 64-bit compatibility by adding the PTRSAFE keyword.
Once you have successfully inspected your code if CHANGED, DEPRECATED or REDESIGNED items were found will be to start debugging your code. We suggest you perform a full test pass on your code, inspecting each function. If problem are found and you break into the debug of your code, check to see if there is a VSTO Code Compatibility Inspector comment above that line. If there is, it should give you direction on the type of problem occurring in that line of code and will contain a URL that you can copy and paste into your browser to get more information. Once you have completed verifying your code for Office 2010 compatibility, you can remove the comments from the code by clicking the Remove VSTO Inspector Comments on the Tools menu:
As we mentioned in our previous post on OEAT – we will be offering a preview of the tools for Office 2010 application compatibility in early December. We also recommend you stay tuned to the Office 2010 public beta to be delivered in November as well, so that you can experiment with getting your 2003 and 2007 solutions to work with Office 2010.
If you would like to sign up for the beta of OEAT and CI, please send an email to this address: mailto:OFAPPCPT@Microsoft.com.