Creating a VBA-Enabled Version of Duwamish Books

Duwamish Books, Phase 3.5: VBA

Ade Miller
Summit Software Company

December 1999

Summary: Provides details on the Microsoft® Visual Basic® for Applications (VBA) customization design and deployment tools added to Phase 3.5: VBA. (4 printed pages) Discusses:

Contents

Introduction
Architecture Overview
Providing an MT Project Design Tool
Deploying Projects

Introduction

Phase 3.5 of Duwamish Books factored the Phase 3.0 client functionality across two tiers, deploying the business logic as Microsoft Transaction Server (MTS) components on the middle tier. Phase 3.5: VBA demonstrates how VBA customizations can be authored and deployed to the middle tier. Phase 3.5: VBA allows customizations to be written against two areas of the Business Logic Layer (BLL):

Architecture Overview

Figure 1. Duwamish Books, Phase 3.5: VBA Windows DNA architecture

Figure 1 shows a three-tier architecture, with the original elements of Duwamish Books, Phase 3.5 shaded. Phase 3.5: VBA adds a new client, the Modifier, to author MT VBA Projects and deploy them onto the middle tier, where they are stored in the "MT Project Store." The MT Project Store is a directory tree containing a uniquely named directory for each customization type.

Customizing Duwamish Books with VBA requires the user to launch the Modifier and create a new VBA Project using the VBA integrated development environment (IDE). Saving the project automatically stores it on the Business Logic Tier. The Modifier client also allows the user to register the MT Project on the Business Logic Tier server so that existing BLL components can then load the project DLL.

This architecture hides the creation of MT DLLs by VBA. The Modifier client user simply loads and saves projects from within the Modifier. These projects are persisted and compiled by the Modifier during the save process.

VBA enabling the BLL does not necessitate any modifications to the existing clients as binary compatibility with the original 3.5 BLL can be maintained. In the case of the Order Entry client and the InsertOrder method some changes were made to allow the BLL method to return error information to the client. This allows the VBA programmer to use the RaiseError method to communicate error information to the Order Entry client user. An additional Buyer client also ships with Phase 3.5: VBA, but this is simply to demonstrate another form of customization rather than any special knowledge of the VBA-enabled BLL.

Providing an MT Project Design Tool

Figure 2. The Modifier client showing an installed Order customization and saved Buyer customization

The Duwamish Books Modifier is a VBA-enabled application for authoring and deploying MT Projects. It presents the user with a list of available projects for both the Buyer and Order customization projects stored in the MT Project Store on the BLL server. These MT Project Store Views show the Project's name, ProgID, and its installation status.

The Modifier uses the Application Programmability Component (APC), part of the VBA 6.0 SDK, to integrate VBA only to the level of being able to support authoring of MT Projects. It is not possible to write VBA code to run against the Modifier itself. It is possible, however, to extend the architecture discussed here to use VBA to customize further aspects of the BLL and the workflow within each of the 3.5 client applications.

Modifying the VBA IDE

The Modifier hides details of the MT VBA architecture from the user as much as possible. The user simply loads and saves Projects to the MT Project Store; no knowledge of the underlying architecture is required.

The VBA IDE includes menu items that are not applicable to middle-tier customization. VBA code written against the Duwamish Books programmability models runs within MTS components, so UserForms are not appropriate. Forms displayed by VBA code running within the BLL components would be displayed on the MTS server, rather than the client, causing the MTS component to hang without the user being able to respond to the UserForm.

The MtIdeRemodeller class provides a layer between the VBA IDE and the application, modifying the VBA IDE as follows:

Persisting and Deploying MT Projects

The Modifier uses two components to persist and deploy MT Projects: the RemoteDeployment and the VBAProjectExporter. These are used in conjunction with the IDE remodeler to make the persistence and deployment of MT Projects as transparent as possible to the VBA programmer customizing the Duwamish Books BLL components.

VBA stores MT projects as .vba files and creates DLLs containing the executable code. The VBAProjectExporter merges the .vba files and the MT DLLs and persists them as compound files, or VLLs. The exporter also stores some additional information, such as the GUID of the programmability object used by the project. The .vll files behave exactly like the original MT DLLs but have the MT Project source code appended to the end.

Note   The 6.2 version of the SDK (shipping after Duwamish Books, Phase 3.5: VBA) will contain fixes, making some features of the VBAProjectExporter and Modifier client obsolete. Two versions of the Modifier client and VBAProjectExporter ship with Phase 3.5: VBA, for VBA 6.0 SDK versions 6.1 and 6.2. The 6.2 version demonstrates the new features of the SDK. The source code contains "#if APC62 Then … #Else … #End If" sections and Visual Basic Project (VBP) files for both the 6.1 and 6.2 versions of the SDK.

The Modifier client uses the RemoteDeployment component to deploy projects on the middle tier.

Deploying Projects

The RemoteDeployment component maintains the MT Project Store on the middle-tier machine. It creates a unique directory for each Customization project being deployed. VLL files can be saved and loaded by the Modifier client directly from the MT Project Store. The Modifier can also query the RemoteDeployment component for a list of currently saved and deployed projects.

The RemoteDeployment component uses DCOM to pass the .vll files created by the VBAProjectExporter on the Modifier to and from the MTS server hosting the Duwamish Books BLL and RemoteDeployment components. VLL files are passed as byte arrays. The RemoteDeployment component also provides methods to allow the Modifier client to browse the saved MT Projects by returning arrays of Project Names and ProgIds. Further methods on the RemoteDeployment component allow MT Projects to be installed and uninstalled on the remote server.