Share via


Office 2010 Application Compatibility: Deep dive on the Code Compatibility Inspector

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.

Visit the prior post on App compat. Visit the drill down on the environment assessment tool.

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:

 https://blogs.technet.com/photos/gray_knowlton/images/3292846/original.aspx

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:

  1. Open the desired document in PowerPoint/Word/Excel.

  2. On the Developer Tab, click Inspect VBA Code.

     https://blogs.technet.com/photos/gray_knowlton/images/3292847/original.aspx

  3. On the Inspect VBA Project dialog, select the options you want, then click Inspect.

 https://blogs.technet.com/photos/gray_knowlton/images/3292848/original.aspx

  1. The Inspect Visual Basic for Application Projects has to be checked in order to inspect your VBA project for potential Object Model changes.
  2. The Inspect Declare Statements will make your project 64bit compatible. Select this option if:
    1. Your project will only be run on Office 2010.
    2. May be run on a system running 64bit Office 2010.
  3. The Add comments option will place comments in your code where potential compatibility issues are discovered. These comments will appear similar to the following:

 https://blogs.technet.com/photos/gray_knowlton/images/3292850/original.aspx

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.

  1. The Detailed Report option will create a text file report at the end of the inspection process. This report will contain the following information:

    SUMMARY:

    ========

    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

    DETAILS:
    ========
    MODULE:                            clsPPTEvents
    FUNCTION:                         PowerPointApp_WindowSelectionChange
    LINE:                                      20
    TYPE:                                     CHANGE
    ITEM:                                    Presentation.SlideMaster
    URL:                      
    CODE:                                   Set objMaster = ActivePresentation.SlideMaster
    MODULE:                            clsPPTEvents
    FUNCTION:                         PowerPointApp_WindowSelectionChange
    LINE:                                      37
    TYPE:                                     CHANGE
    ITEM:                                    Presentation.TitleMaster
    URL:                      
    CODE:                                   Set objMaster = ActivePresentation.TitleMaster

  1. 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):

 https://blogs.technet.com/photos/gray_knowlton/images/3292851/original.aspx

  1. Total Lines Scanned – the total number of VBA code lines scanned in the document.
  2. Total items found – this is the total number of declare statements updates, changed items, deprecated item and design change items found in the code.
  3. 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.
  4. Changed items – these are the items found where the syntax of the command were changed and may need to be updated.
  5. 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.
  6. 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.

Comments

  • Anonymous
    November 23, 2009
    Thank you for the information. I have same experience with the OMPM and have two questions regarding the CCI.
  1. Will I be able to use the CCI with Office 2007? I am aware that some results will not be accurate. But I have a lot of customers with reeeaally old documents, that tool can help them to separate "good" and "bad" documents.
  2. Will the CCI be client-user only? Or will there also be a version which I can fire up and say "go, crawl thru this fileserver and mark all vba-code you can open. And give me a report afterwards"? Thank you
  • Anonymous
    November 23, 2009
    @Martin Nothnagel Martin, On 1 - CCI will only install into Office 2010. Office 2010 compatibility is our scope and when we point out the OM changes that impact the code running in Office 2010 and as developer remediate the found changes, they would need to be tested in Office 2010. On 2. - let me just say that you will be able to bulk assess macros. Please watch this blog for more details :)