Programming Technologies

Archived content. No warranty is made as to technical accuracy. Content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
On This Page

Visual Basic for Applications
Architecture for COM Add-ins
Custom Project Guide Solutions
OLE DB Provider and Data Access Pages

Visual Basic for Applications

Automation is the Component Object Model (COM) technology that makes Microsoft® Project 2002 programmable, which makes creating an integrated Microsoft Project solution possible. Automation (formerly called OLE Automation) includes the following features.

  • Automation exposes features in a hierarchy of programmable objects Applications, dynamic-link libraries (DLLs), and ActiveX® controls that support the appropriate Automation interfaces expose their features as a set of programmable objects. Any application or service that supports these interfaces is called a COM component. The set of programmable objects that a COM component exposes is organized into a set of hierarchical relationships that is called an object model, or a programming model.
  • Automation allows applications to share features with other applications A COM component can be either an Automation server that shares its component objects with other applications or an Automation client that uses the component objects of other applications.
  • Visual Basic for Applications provides features that make it easy to use Automation When you use Microsoft Visual Basic® for Applications (VBA) code, you can establish a reference to the programming model of an Automation server by using the References dialog box (Tools menu) in the Visual Basic Editor. The reference allows your solution to allocate memory efficiently to work with the objects that the Automation server exposes. The reference also allows the Visual Basic Editor to assist you when you enter VBA statements by automatically listing relevant objects, properties, and methods from the referenced programming model. And you can use the Object Browser command (View menu) to examine how the objects that are exposed by the Automation server are related to each other, and to find more information about how to program the objects.

Automation Servers and Automation Clients

Microsoft Project developers can take advantage of all Automation features when developing custom solutions. Microsoft Project can function as COM components that expose most of their features to other applications that support Automation as programmable objects. Microsoft Project serves as both Automation server and Automation client. Microsoft Project incorporates the VBA programming environment that makes working with Automation easy.

Programmable Applications

The Visual Basic for Applications programming language and the Visual Basic Editor are incorporated into Microsoft Project to make it programmable.

In addition, many other applications incorporate the Visual Basic for Applications programming environment and are written to expose their functionality to VBA programmers through Automation interfaces. This means that developers can use Visual Basic for Applications to create solutions not only for Microsoft Project, but also for other applications that support VBA and Automation.

Programming across applications

Visual Basic for Applications and Automation allow you to program Microsoft Project. Developers can also use Automation to run other applications from within a client application. For example, a VBA solution developed in Microsoft Project can run a hidden instance of Microsoft Excel to perform mathematical and analytical operations on Microsoft Project data.

Working with programmable services

Automation also allows developers to use Visual Basic for Applications code to work with programming models that function as freestanding services and are independent of individual applications. For example, Microsoft Project installs the Microsoft Data Access Components (MDAC), which consist of OLE DB components that provide low-level access to a variety of data sources and components that make up the ActiveX Data Objects (ADO) programming model. Because the ADO programming model supports Automation, you can use ADO from Visual Basic for Applications code running in Microsoft Project to gain access to and work with any data source that is available through an OLE DB provider or an Open Database Connectivity (ODBC) driver.

New programming features

Extensive changes have been made to the Microsoft Project 2002 object model and events to support new and improved features in the application. Many objects, properties, and methods have been replaced. To provide backward compatibility, most of the replaced components have been hidden rather than removed. This means that they do not appear in the object browser by default, however, old code that uses the hidden components will still work correctly without modification. When you write new code, however, you should use the new objects, properties, and methods.

New objects

The following objects have been added to the Microsoft Project 2002 object model:

  • EventInfo parameter added to events to provide cancel information.
  • Filter and Filters to provide access to filters in Microsoft Project.
  • Profile and Profiles to provide access to profiles in Microsoft Project.
  • Table and Tables to provide access to tables and table formats in Microsoft Project.
  • TableField and TableFields to provide access to table fields and their formatting in Microsoft Project.
  • View and Views to provide access to views in Microsoft Project.
  • ViewCombination and ViewsCombination to provide access to combination views in Microsoft Project.
  • ViewSingle and ViewsSingle to provide access to single-pane views in Microsoft Project.

New events, properties, and methods

Many new events, properties, and methods have been added for numerous objects in Microsoft Project 2002. For a complete list of all new events, properties, and methods, see Visual Basic for Applications Help.

Hidden properties and methods

Most of the hidden properties and methods have been replaced by new functionality in Microsoft Project 2002. These properties and methods are supported only for backward compatibility; for new code, you should use the replacement functionality provided in Microsoft Project 2002. Visual Basic for Applications in Microsoft Project 2002 contains the following hidden properties and methods for visible application objects for which no replacements are available:

  • HelpQuickPreview
  • MailUpdateProject

Methods with new, changed, or deleted arguments

Visual Basic for Applications in Microsoft Project 2002 provides several methods for which arguments have been added, changed, or removed. Any code that uses these items may produce errors and should be modified accordingly. For a complete list of methods with new, changed, or deleted arguments, see Visual Basic for Applications Help.

See Also

For more information about the Visual Basic for Applications programming language and applications that support it, see the Microsoft Visual Basic for Applications Web site.

For more information about developing custom solutions by using Office applications and the Visual Basic for Applications programming language, see the Office XP Developer Web site, and the Microsoft Office 2000/Visual Basic Programmer's Guide.

Architecture for COM Add-ins

Instead of using macros and Visual Basic for Applications scripts to customize Microsoft Project, you can create a custom Microsoft Project solution by developing and distributing an add-in. An add-in extends an application by adding functionality that is not in the core product. For example, an add-in might add new menu commands or toolbar buttons that display custom forms to add new features to an application.

Microsoft Project supports a COM add-in architecture that allows developers to create a single add-in that can run in any application. VB developers can create COM add-ins by using the Building COM Add-ins for Office Applications article on MSDN.

COM add-ins can be created by developers who are using one of the following programming languages:

  • Microsoft Visual Basic versions 5.0 or later
  • Microsoft Visual C++
  • Microsoft Visual J++
  • Any language that can create COM components

This wide support for COM add-ins means that developers can now use multiple development environments to create custom solutions in Microsoft Project. The only requirement to connect COM add-ins to Microsoft Project is for the add-in to implement the IDExtensibility2 interface. COM add-ins can be loaded when the host application starts, or they can be loaded on demand. Support has also been added to allow the OnAction property of a custom command bar button to load a COM add-in.

Microsoft Project provides the following add-ins:

  • Adjust Dates
  • Analyze Timescaled Data
  • PERT Analysis

The following COM add-ins for Microsoft Project 2002 are available at the Microsoft Download Center:

See Also

For more information about creating COM add-ins, see the Microsoft Office 2000/Visual Basic Programmer's Guide.

For more information about creating COM Add-ins, see the Building COM Add-ins for Office Applications article on MSDN.

For information about downloading Microsoft Project 2002 COM add-ins, see the Microsoft Download Center.

Custom Project Guide Solutions

The Microsoft Project 2002 Project Guide was developed to make Microsoft Project easier to use for beginning users. It provides a new interface element that complements the existing, and still familiar, Microsoft Project interface. The Project Guide can be customized and extended for your organization. For example, your organization may want to change particular steps within a project management process, outline their own unique processes, and add links to additional information.

Using the following Microsoft Project 2002 object model properties on the Project object, you can define a custom Project Guide for a project:

  • ProjectGuideUseDefaultFunctionalLayoutPage This is a Boolean property. If set to True, the default HTML page, referenced as gbui://mainpage.htm, defines the layout and functionality of the user interface for the Project Guide. If set to False, the HTML page referenced by the property ProjectGuideFunctionalLayoutPage is used.
  • ProjectGuideFunctionalLayoutPage This is a Read/write string property on the Project object. It returns or sets the HTML page that should be used to define the layout and functionality of the Project Guide for the specified project. Note that this property is used only if ProjectGuideUseDefaultFunctionalLayoutPage is set to False.
  • ProjectGuideUseDefaultContent This is a Boolean property. If True, the default XML document, referenced as gbui://gbui.xml, defines the content for the Project Guide. If False, the XML document referenced by the property ProjectGuideContent is used.
  • ProjectGuideContent This is a Read/write string property on the Project object. It returns or sets the XML document that should be used to define the content of the Project Guide for the specified project. This property is used only if ProjectGuideUseDefaultContent is set to False.

Each project can have its own Project Guide with different layout, functionality, and content. Potentially, a company or solution provider could create one Project Guide for finance projects, another for engineering projects, and so on. There could also be different Project Guides based on the role of the user. Project Guides based on user roles would involve checking a user's role when he or she opens a project and dynamically changing the properties that define the Project Guide for that project. When the properties defining the Project Guide for a project are changed, the HTML pages displayed in that project are refreshed, so the new Project Guide is displayed immediately. You do not have to close and open the project again for the changes to take effect.

Most organizations will typically only customize the content properties of the Project Guide, ProjectGuideUseDefaultContent, and ProjectGuideContent. The default functionality and layout page (defined by the properties ProjectGuideUseDefaultFunctionalLayoutPage and ProjectGuideFunctionalLayoutPage) should work for most custom Project Guides. Only consider changing the functionality and layout page to change the default layout of the Project Guide, for instance, to have the side pane displayed on the right side of the view area instead of the left, or to tile the side pane horizontally with the Project window instead of vertically. Some of the default behavior of the Project Guide, such as the way it responds to view changes, can also be customized. The default functionality and layout page (gbui://mainpage.htm) has been written generically, so it should work for most custom scenarios.

The properties defining the Project Guide are displayed in the Interface tab of the Options dialog box (Tools menu) in Microsoft Project 2002. A Microsoft Project user accesses this tab to change the Project Guide for a project or to set the default Project Guide for all projects (using the Set as Default button). Instead of allowing individual users to change Project Guide settings, it is expected that organizations will set up the Project Guide for the entire organization or group so that these changes apply to all users.

For more information about custom Project Guide solutions, see the Microsoft Project 2002 Project Guide Architecture and Extensibility or Introduction to Customizing the Microsoft Project Guide articles on MSDN.

OLE DB Provider and Data Access Pages

Microsoft Project 2002 OLE DB Provider

OLE DB consists of a collection of component object model (COM) interfaces to various database management system services. OLE DB provides access to a particular data source by using a COM component called a data provider, which is often referred to as an OLE DB provider. If the system that the Microsoft Project solution runs on has the appropriate OLE DB provider installed, as well as the core ActiveX Data Objects (ADO) and OLE DB components installed with Microsoft Project, that solution can use ADO code to work with the data exposed by that provider.

You can use the Microsoft Project OLE DB providers to access project data. If the data is stored in a Microsoft Access or Microsoft SQL Server™ database, you can also use the Jet 4.0 OLE DB provider. If the data is stored in a SQL Server or Microsoft Data Engine (MSDE) database, it can be accessed using the SQL OLE DB provider.

What's New in OLE DB

OLE DB in Microsoft Project has been expanded and includes the following enhancements:

  • Improved reporting capabilities using data access pages, including support for two extended properties: Caption returns friendly names for all fields in the database, and SubstituteExpression returns duration, work, cost, timephased, and cost rate values for certain data types and is linked to an ActiveX control specific to Microsoft Project called MSPJFormat in the data access page.
  • To view data access pages on a local provider, you need to use Access 2002, along with Microsoft Project 2002 installed on the computer viewing the provider. Microsoft Project automatically installs the OLE DB Provider, any international .dll file, the appropriate registry keys, and any needed ActiveX controls.
  • To view data access pages on a remote provider, you need both the Microsoft Project ActiveX control and the appropriate Textconv.dll on the local computer.
  • Friendly field names have been added to the OLE DB Provider, for example, TaskConstraintDate. Friendly field names allow the database to be localized and allow custom reports to be created in languages other than English. In addition, users should see field labels in their localized languages.
  • Field labels are not displayed in languages other than English when Microsoft Project is running in enterprise mode.
  • Support for timephased data through the addition of 15 new tables, 5 each for assignments, resources, and tasks; broken out by minute, hour, day, week, and month.
  • The database uses a consistent format for all timephased table names: tableTimephasedBytime, for example, AssignmentTimephasedByMinute.
  • Enterprise and non-enterprise modes for the OLE DB Provider. Enterprise fields are noted in the table descriptions with an E in the left column. Enterprise fields are available only in Microsoft Project Professional.
  • Additional support for Office Web Components. This support shares the same basic functionality as the Caption and SubstituteExpression properties for data access pages.

For more information about accessing Microsoft Project data through the Microsoft Project 2002 OLE DB provider, including the full list of limitations and the table structures exposed through OLE DB, see the file Prjoledb.htm located on the Microsoft Project 2002 CD in the folder \FILES\PFILES\MSOFFICE\OFFICE10\1033\ (1033 is the locale ID [LCID] for the U.S. English version, the subfolder for a localized version will depend on its LCID). You may also find the Accessing Data with ADO article on MSDN useful when developing Web-based data access applications.

Accessing the OLE DB Table Structure Using Data Access Pages in Microsoft Access

Data access pages in Microsoft Access provide a versatile and powerful method for generating reports using data from Microsoft Project. They also provide a convenient way to view the Microsoft Project OLE DB table structure. For more information on data access pages, see Microsoft Access Help.