Microsoft KB Archive/118817

= INFO: Summary of Sample Applications on the ODK 1.0 =

Article ID: 118817

Article Last Modified on 11/3/2003

-

APPLIES TO


 * Microsoft Visual Basic 3.0 Professional Edition
 * Microsoft Office 97 Developer Edition

-



This article was previously published under Q118817



SUMMARY
The Microsoft Office Developer's Kit (ODK) includes several useful samples for Visual Basic Programmers. This article summarizes the sample applications included in the ODK.



ChartDem: Demonstrates the Microsoft Excel 5.0 Chart Objects
ChartDem uses a Microsoft Visual Basic version 3.0 interface with the OLE control to display all of the objects related to Microsoft Excel charts. The user can select objects by name from drop-down lists or enable a timer that cycles through the objects.

The code for ChartDem demonstrates several OLE Automation techniques for integrating Visual Basic version 3.0 with Visual Basic for applications:
 * Navigating from the application object to each of the chart-related objects.
 * Calling Visual Basic Applications Edition procedures from a Visual Basic version 3.0 program, and using the names of those procedures as though they were function pointers.
 * Linking Microsoft Excel objects to a Visual Basic version 3.0 OLE control at run time.
 * Using the OLE control to display an object while changing the properties of the object through a hidden instance of the application object.
 * Writing code that is portable between Visual Basic version 3.0 and the Applications Edition of Visual Basic.

The application consists of two parts: a Visual Basic version 3.0 program, which manages the user interface, and a workbook, which contains all of the Visual Basic Applications Edition procedures used to change object properties. You can copy most of these procedures to Visual Basic version 3.0 and run them without making any code changes.

Encore: An Integrated Solution Using OLE and Microsoft Office
Encore is a sample application developed using Microsoft Visual Basic for applications and Microsoft Office. It is a forecasting tool for Encore Musical Instruments, an international firm. By using OLE, Encore demonstrates the ease in creating custom solutions among multiple applications.

From Microsoft Excel, Encore uses OLE Automation Objects and Visual Basic for Applications macros both to access sales-planning data in Microsoft Project and to create and distribute forecast reports in Microsoft Word. Another innovation of the Encore application is its use of pivot tables, a new feature of Microsoft Excel 5.0 that allows you to summarize large amounts of data using format and calculation methods of your choice.

Encore incorporates the functionality of Microsoft Excel version 5.0, Microsoft Word version 6.0, and Microsoft Project version 4.0.

FindXL: A Utility that Locates Hidden Instances of Microsoft Excel
Controlling OLE objects in Microsoft Excel from Microsoft Visual Basic version 3.0 is one of the many ways to use the OLE Automation capabilities of Microsoft Office to create custom applications. While developing and testing applications created in this way, a run-time error in Visual Basic version 3.0 may leave a hidden instance of Microsoft Excel running, invisible to the Task Manager. FindXL is a simple tool for locating such hidden instances and making them visible.

Visual Basic version 3.0 Professional Edition contains a tool, WPS.EXE, for finding and eliminating dynamic-link libraries and hidden executable files, but that tool provides neither a graceful exit nor an opportunity for examining the state of the hidden executable file. By making the hidden instance of Microsoft Excel visible, FindXL allows you to look at the property settings of the OLE objects at the time of the error.

The Visual Basic version 3.0 source code for FindXL demonstrates the use of the GetObject function with the Microsoft Excel Application object.

Help Desk: Demonstrates OLE Between Visual Basic and Microsoft Excel
The Help Desk sample application is a Microsoft Visual Basic version 3.0 program that demonstrates OLE functionality by manipulating Microsoft Excel 5.0 Automation objects. It is a way to effectively manage software support.

With this application, you can manage the names of software systems, information on technical service representatives using Help Desk, the names and phone numbers of contacts for whom the system is developed, and details of technical-service requests or calls about a system. An integral part of the application is the call-reporting functionality provided by an embedded Microsoft Excel 5.0 worksheet in which call data can be displayed and charted.

Help Desk was built using Microsoft Visual Basic version 3.0 and incorporates the functionality of Microsoft Excel version 5.0.

Invoice: Demonstrates OLE 2 Between Visual Basic 3.0 and Word 6.0
The Invoice sample application is a Microsoft Visual Basic version 3.0 program that demonstrates OLE functionality by manipulating Microsoft Word version 6.0 Automation objects to print invoices. For a single invoice, a form is printed using OLE Automation. The Microsoft Word Mail Merge feature is used when printing multiple (or batch) invoices.

An innovation of the Invoice application is its use of form fields, a new feature of Microsoft Word version 6.0 that allows you to print the invoice information as a custom form or as a preprinted form.

Invoice was built using Microsoft Visual Basic version 3.0 and incorporates the functionality of Microsoft Word version 6.0.

Mailing List: Demonstrates OLE Between Visual Basic 3.0 and Word 6.0
The Mailing List sample application is a Microsoft Visual Basic version 3.0 program that demonstrates OLE functionality by manipulating Microsoft Word version 6.0 Automation objects.

With this application you can manage the names and addresses of individuals, the names of mailing lists, and any association between them. It enables you to easily perform mail merge operations using the data records of individuals in a mailing list and a Microsoft Word version 6.0 document.

Mailing List was built using Microsoft Visual Basic version 3.0 and incorporates the functionality of Microsoft Word version 6.0.

MenuDemo: Demonstrates Various Microsoft Excel Objects
MENUDEMO.XLS is a Microsoft Excel workbook that demonstrates manipulation of several of the OLE Automation objects exposed by Microsoft Excel, using Visual Basic, Applications Edition. Most of the procedures in the workbook are excerpts from the object reference topics in "Programming Integrated Solutions with Microsoft Office," Chapter 4, "Microsoft Excel Objects."

The workbook contains modules and worksheets illustrating the following objects:  MenuBar, Menu, and MenuItem objects: The wsExploreMenus worksheet presents a simple drill-down interface to the menu bars, menus, and menu items in Microsoft Excel. The worksheet also has buttons for creating and destroying a custom menu bar that has cascading submenus. The modMenus module contains code to generate the lists of objects and to add, activate, and delete the custom menu bar. Listbox object: The interface on the wsExploreMenus worksheet shows the use of listboxes on a worksheet. The listboxes are linked by their OnAction procedures, contained in module modMenus. For example, when the user selects a menu bar from the first listbox, the second listbox is automatically filled with the menus belonging to that menu bar. Areas object: Three sheets illustrate the use of the Areas object to obtain a list of the simple rectangular ranges within a selection of discontiguous cells. The worksheet wsAreas contains several discontiguous-named ranges, which can be selected using Goto (F5); pressing a button on the sheet causes a procedure in modAreas to iterate the Areas collection of the selection, fill the listbox on dialog-sheet dlgAreas, and display the dialog box. Window object: The modWindowObject module contains a procedure that switches a window on a worksheet in and out of Formula display mode. PageSetup object: The modPageSetup module contains a procedure that causes the PageSetup dialog box to set the range to be printed equal to the current selection. Spinner object: The modSpinner module shows a set of functions that work together to display a spinner control to the right of a cell if:

 The user double-clicks the cell. -and-

</li> The cell contains an integer from -32,000 to +32,000 (the range limits of the spinner control).</li></ul>

The code demonstrates both setting OnEntry and OnDoubleClick properties and iterating the Spinners collection to find a specific named instance of the Spinner control.</li></ul>

MenuDemo incorporates the functionality of Microsoft Excel version 5.0.

Northwind Management System: An Integrated Solution Using Microsoft Office
The Northwind Traders Management System sample application demonstrates how to program an integrated solution using the following applications:
 * Microsoft Access
 * Microsoft Excel
 * Microsoft Mail
 * Microsoft Visual Basic
 * Microsoft Word

The Northwind Traders Management System provides a top-down view of the Northwind Traders business data. It enables employees of this fictitious company to keep track of important corporate data so they can make better decisions about everything from manufacturing and inventory to product marketing.

The data resides in a Microsoft Access database (NWIND.MDB) and is shared with a Microsoft Excel workbook (NWIND.XLS). The sample application displays and manipulates this data using OLE Automation objects and code that resides in a Visual Basic application (NWIND.EXE). News articles are displayed using Microsoft Word (NWIND.DOC) in an OLE Automation object.

The Northwind Traders Management System application was built using Microsoft Visual Basic version 3.0 and incorporates the functionality of Microsoft Excel version 5.0, XLODBC.XLA, and Microsoft Word version 6.0.

OLEDB: Demonstrates Storing and Retrieving OLE Objects in a Database
NOTE: This reference to OLEDB is just a sample named OLEDB and does not have anything to do with OLE DB technology introduced by Microsoft.

The OLEDB sample application is a Microsoft Visual Basic version 3.0 program that demonstrates OLE functionality by manipulating data access objects. OLEDB allows you to add, delete, view, and edit OLE objects in a Microsoft Access database. The database can contain Word documents, Microsoft Excel spreadsheets, wave files, bitmaps, text files, and so on.

OLEDB demonstrates the use of the Visual Basic GetChunk and AppendChunk methods to store and retrieve large amounts of data in a Microsoft Access binary field. The OLEDB.BAS file contains reusable Visual Basic routines for storing and retrieving OLE objects, files, or any other data.

OLEDB was built using Microsoft Visual Basic version 3.0.

SetObjNm: A Single Function that Changes Object Names in Microsoft Excel
SETOBJNM.XLA is a simple but useful example of an add-in. Its purpose is to make it easy to change the default name of a graphic object, such as a button on a dialog sheet, from "Button 2" to "cmdOK" or whatever your coding standards dictate. On installation, the add-in puts a toolbar button on the Forms toolbar, using the ToolTip text "Set Object Name." Selecting a graphic object and clicking the Set Object Name button displays the default name of the object and allows you to change it.

The source file, SETOBJNM.XLS, demonstrates the following:
 * Installing and uninstalling an add-in.
 * Searching a collection.
 * Displaying a simple dialog box.
 * Using object navigation paths to add a ToolbarButton object to a Toolbar object.
 * Storing and setting toolbar button faces.
 * Setting ToolTip text for a toolbar button.

A second workbook, SETOBJN1.XLS, contains code from the EditBox reference section in "Programming Integrated Solutions with Microsoft Office," Chapter 4, "Microsoft Excel Objects." It demonstrates the same functionality as the add-in, but uses an uncompiled workbook.

SetObjNm incorporates the functionality of Microsoft Excel version 5.0.

VisiBase: Demonstrates OLE Between Visual Basic 3.0 and Microsoft Word 6.0
The VisiBase sample application is a Microsoft Visual Basic version 3.0 program that demonstrates OLE functionality by manipulating Microsoft Word version 6.0 Automation objects.

This application enables you to modify data about each employee in a company, including a scanned photograph of the employee and a brief biography. This data, along with the photo, is automatically inserted into a Microsoft Word template, ready for publication in a company newsletter. The same Visual Basic front end could be used, with minor modifications, to automate the creation of security ID badges, a yearbook, and so on.

VisiBase was built using Microsoft Visual Basic version 3.0 and incorporates the functionality of Microsoft Word version 6.0.

Additional query words: examples programs

Keywords: kbinfo kbprogramming KB118817

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.