Home Access Archon Code Samples Bibliography Office Books Downloads Links Helen's Handknits

Here are some code samples showing you how to exchange data among Office applications.

horizontal rule

emailBlue.gif (2778 bytes) When sending me e-mail about a code sample, please be sure to include the code sample's number.
03right.jpg (1880 bytes) indicates data flow direction
List of all code samples

 

bullet

Access

No. VB Dialect Title
Date Last Uploaded
Summary File to Download
1 VBA Create two Access add-ins

4/21/1998

Describes the creation of two Access add-ins:   one is a Text Box Design Wizard; the other is a Form Picture Property Builder.   Includes a library database with working add-ins. code1.zip

224 KB

4 VBA An Access 97 add-in that applies the Leszynski Naming Convention to database objects

Updated

7/3/1999

An add-in that renames database objects (tables, queries, forms, reports, macros and modules), as well as controls on forms and reports, according to the Leszynski Naming Convention (LNC). This add-in was originally featured in a three-part article series in Smart Access, in the summer of 1998. The zip file includes a trial version of Rick Fisher's Find And Replace add-in.  Use this version for Access 97. code4.zip

1.5 MB

code4NoFAR.zip

470 KB

 

10 VBA An Access 2000 add-in that applies the Leszynski Naming Convention to database objects

Updated

29-Jan-2011

An add-in that renames database objects (tables, queries, forms, reports, macros and modules), as well as controls on forms and reports, according to the Leszynski Naming Convention (LNC). The Access 97 version of this add-in was originally featured in a three-part article series in Smart Access, in the summer of 1998.   Now supports your own custom LNC tags. The zip file includes a trial version of Rick Fisher's Find And Replace add-in.  Works in Access 2000 through 2003.  code10.zip

2,607 KB

code10NoFAR.zip

964 KB

11 VBA An Access 97 add-in that creates a main menu for a database.

6/13/1999

This add-in creates a main menu for an Access database, with drop-down lists of forms and reports for selection, and option buttons for selecting report mode and date range. This add-in was originally featured in an April 1999 Smart Access article. code11.zip

740 KB

12 VBA An Access 2000 add-in that creates a main menu for a database.

Updated

13-Jan-2004

 

This add-in creates a main menu for an Access database, with drop-down lists of forms and reports for selection, a backup button, and option buttons for selecting report mode and date range. The Access 97 version of this add-in was originally featured in an April 1999 Smart Access article.  Works in Access 2000 through 2003. code12.zip

1523 KB

20 VBA An Access 2002 add-in that creates backups of front and back end databases, copies of database objects, and listings of table and query fields.

7-Aug-2007

Lets you back up front end Access databases and the most common types of back end databases (Access .mda and .accda, Excel .xls and .xlsx, comma-delimited and fixed-width text files), and make copies of database objects (individually or in groups); also lists table and query fields, by table field order or alphabetically. Lets you specify a custom backup prefix or suffix for database object backups. Works in Access 2002 or higher.

code20.zip

799 KB

 

22 VBA An Access 97 add-in that lets you apply one of a set of design schemes to forms in a database

7/8/2001

This add-in lets you apply one of a set of four standard color schemes, or a custom color scheme you create, to a new form you are creating, or to an existing form (or selection of forms).  The add-in uses the CommonDialog control that comes with the ODE for Access 97.

code22.zip

665 KB

26 VBA Demonstrates selecting report sorting fields and filter values from a form

9/12/1999

The sample database has a table of sample data, two reports, and two forms, which use combo boxes and a multi-select list box to let users select fields for sorting, or values for filtering the selected report.

code26.zip

82 KB

36 VBA An Access 2000 add-in that lets you apply one of a set of design schemes to forms in a database

Updated

29-Aug-2008

This add-in lets you apply one of a set of four standard color schemes, or a custom color scheme you create, to a new form you are creating, or to an existing form (or selection of forms).  The add-in uses the CommonDialog replacement code from the Access 2000 Developers Handbook. Works in Access 2000 through 2003.

code36.zip

696 KB

 

37 VBA Sample query column expressions for splitting and concatenating name and address data

8/19/2001

Tables of sample data, either split into name and address components or with name (and address) components combined into single fields, with select and append queries to either parse out the separate components (such as Address1, Address2, Address3, LastName, MiddleName, FirstName), or concatenate separate components into combined fields (LastNameFirst, Address).  Expressions can also be used in VBA code.  Works in any version of Access.

code37.zip

68 KB

 

 

42 VBA An Access 2002 database that stores information about ebooks, printed books and audio books

Updated

28-Feb-2008

Demonstrates use of the Controls collection of a form and the Tag property of form controls to fill an array with data from the current record, for use in creating a new record with mostly the same data.

code42.zip

1,845 KB

62 VBA An Access 2007 add-in that applies the Leszynski Naming Convention to form and report controls

29-Jan-2011

An add-in that renames controls on forms and reports according to the Leszynski Naming Convention (LNC).  Works in Access 2007 through 2010.

code62.zip

1,189 KB

 

63 VBA An Access 2007 add-in that applies the Leszynski Naming Convention to database objects

29-Jan-2011

An add-in that renames database objects (tables, queries, forms, reports, macros and modules), as well as controls on forms and reports, according to the Leszynski Naming Convention (LNC).  The zip file includes a beta version of Rick Fisher's Find And Replace add-in for Access 2007 and up.  Works in Access 2007 through 2010.  code63.zip

3,484 KB

code63NoFAR.zip

1,334 KB


bullet

Access   03right.jpg (1880 bytes)  Excel

Coming soon

No. VB Dialect Title
Date Last Uploaded
Summary File to Download
         


bullet

Access   03right.jpg (1880 bytes)  Outlook

No. VB Dialect Title
Date Last Uploaded
Summary File to Download
17 VBS Import Access data into Outlook contact items

Updated

9/26/2000

Imports data from a table in an Access database, and uses the data to create Contact items in an Outlook folder.  Shows the syntax for both standard and custom Outlook fields.  Works with both Outlook 98/Access 97 and Outlook 2000/Access 2000. code17.zip

123 KB

 

21 VBS Filling an Outlook Combo Box or List Box from an Access table

Updated

9/26/2000

Fills a combo box or list box on an Outlook form from code, pulling data from the Categories and Customers tables in the sample Northwind database provided with Access.  Works with both Access 97 and Access 2000. code21.zip

51 KB

49 VBA Exporting Contact Data from Access to Outlook

Updated

8/26/2000

Exports contact data stored in an Access table to new Outlook contacts, using a DAO recordset to pick up the data from the Access table, and the Add method of the Contacts folder's Items collection to create new Outlook contacts. Also includes buttons to create different types of Outlook items, and to list the Outlook folders. code49.zip

211 KB


bullet

Access   03right.jpg (1880 bytes)  Word

No. VB Dialect Title
Date Last Uploaded
Summary File to Download
2 VBA Writing an Access Contact to a Word Letter

Updated

7-Aug-2007

Using OLE Automation and Word custom document properties to create a single Word letter based on a template, with data from the current address on an Access form. code2.zip

295 KB

3 VBA Merging Access Data to Word Mailing Labels

Updated

8/9/2000

This code sample prints contact addresses from an Access table to a Word document formatted for Avery #5160 address labels, using a DAO recordset that iterates through the records in the table, and puts one address in each cell of a Word table in the document. code3.zip

138 KB

9 VBA Importing Access Data into a Word Table

Updated

9/26/2000

Imports data from a query in the sample Northwind database into a Word table, and sorts and formats the data to create a grouped report. code9.zip

134 KB

24 VBA Merging to Word Four Ways

6/9/2002

Demonstrates four ways to merge Access data to Word documents – Word document properties, bookmarks, the TypeText method and DDE mail merge.  Both Access 97 and Access 2000 databases are provided; the Access 2000 database also works in Access 2002. code24.zip

508 KB

 

25 VBA Filling a listbox on a Word UserForm with data from Access

7/24/1999

Fills a listbox on a UserForm opened from a Word document with data from the Products table in the sample Northwind database. This code is for Office 2000. code25.zip

16 KB

35 VBA Selecting Access Contacts for a Word Merge Letter from a Multi-Select Listbox

Updated

13-Apr-2005

Fills a listbox on a UserForm opened from a Word document with contact data from an Access table, and generates Word letters to the selected contacts. Works with both Office 97 and Office 2000.  

code35.zip

223 KB


bullet

Excel   03right.jpg (1880 bytes)  Outlook

No. VB Dialect Title
Date Last Uploaded
Summary File to Download
19 VBS Open an Excel worksheet

3/10/1998

This sample includes an Outlook form and an Excel worksheet, demonstrating how to open a worksheet from a command button on the Outlook form. code19.zip

11 KB

61 VBA Create Distribution List from an Excel Worksheet

12-Aug-2007

This sample includes an Excel worksheet with a list of names and email addresses, and a saved VBA module containing a procedure that creates an Outlook Distribution List from data in the worksheet.  Works in Office 2003, and probably in 2000, 2002 and 2007 as well. code61.zip

294 KB


bullet

Outlook

No. VB Dialect Title
Date Last Uploaded
Summary File to Download
5 VBS Change contact items to another form using Item.Add

3/10/1998

This sample includes an Outlook form with a procedure running from a command button which takes data from Contact items in a folder and produces new contact items from a form of your choice. The new items are placed in another folder. You should use the method in Code Sample #28 first; use this only in the rare cases where that method doesn't work. code5.zip

22 KB

14 VBS Work with the Restrict clause

3/10/1998

This sample includes two Outlook forms demonstrating the use of the Restrict clause to select items from another folder and display them in a list box on a page of the form. code14.zip

34 KB

23 VBS Working with Outlook folders

3/10/1998

Demonstrates finding a folder by name, wherever it is located on the folder tree. code23.zip

12 KB

 

28 VBS Updating the message class of a form

Updated

10/9/2000

The Reset Message Class form lets you change the message class (form) for items, to move your data to the new or upgraded form after making design changes. code28.zip

67 KB

43 VBS Parsing a multi-line address

5/3/1998

Shows how to parse two address lines in a multi-line contact address into separate variables representing Line 1 and Line 2, for exporting to another application. code43.zip

14 KB

48 VBS Copying Contact Items to Another Folder

Updated

6/6/1998

Shows how to copy all items (or items filtered by Category) to another Outlook folder. code48.zip

21 KB

51 VBS Extracting an Attachment from a Task and Mailing It

5/25/1998

Demonstrates extracting and saving an attachment from a task item and mailing it as an attachment in a new mail message. code51.zip

29 KB

52 VBS Setting the Date and Time from Code

5/25/1998

Shows how to set the date and/or time for an appointment to start from VBS code, using date/time information entered in text fields on a form. code52.zip

21 KB

53 VBS Conditional Field Validation

6/11/1998

Shows how to apply conditional validation to a field, based on the value of another field; the code runs from the form's Write event code53.zip

15 KB

 

54 VBS Find a Text File and Mail It

6/11/1998

Finds a text file located in one of the standard folders, and mails it as an attachment to an Outlook mail message code54.zip

14 KB

55 VBS Display Contacts in a Combo Box

6/11/1998

Displays contact names or FileAs fields in a combo box on an Outlook form, where one can be selected for further processing code55.zip

17 KB

 


bullet

Outlook  03right.jpg (1880 bytes)  Access

No. VB Dialect Title
Date Last Uploaded
Summary File to Download
7 VBS

VBA

Write Outlook contact and mail message data to an Access table

Updated

4-Dec-2004

This code sample includes an Outlook form and an Access database.  For Office 97, the code writes most of the standard Outlook fields from the current contact item to a new row in a table in the Access database.  For Office 2000 or higher, an Outlook macro (VBA procedure) runs from a toolbar button, to export both standard and custom data from any contact item or mail message. code7.zip

280 KB

 

15 VBA The Outlook Automation Access 97 add-in

6/15/1999

An Access 97 add-in that automates importing data from custom Contact items (any Outlook version), including custom fields, into an Access 97 database. Also includes a function that generates an Access report listing all the fields in the tables in the current Access database. code15.zip

290 KB

16 VBS Export Outlook contact data to an Access table

Updated

11/27/1999

Exports Contact data from items in an Outlook folder to a table in an Access database, and prints a report listing the contacts.  Shows the syntax for both standard and custom Outlook fields.  Works with both Outlook 98/Access 97 and Outlook 2000/Access 2000. code16.zip

79 KB

18 VBA The Outlook Automation Access 2000 add-in

Updated

12/25/2001

An Access 2000 add-in that automates importing data from custom Contact items (any Outlook version), including custom fields, into an Access 2000 database. Also includes a function that generates an Access report listing all the fields in the tables in the current Access database. code18.zip

221 KB

38 VBA The Outlook Automation Access 2002 add-in

12/25/2001

An Access 2002 add-in that automates importing data from custom Contact items (any Outlook version), including custom fields, into an Access 2002 database. Also includes a function that generates an Access report listing all the fields in the tables in the current Access database. code38.zip

240 KB

 

46 VBA The Safe Outlook Automation Access 2002 add-in

 

An Access 2002 add-in that automates importing data from custom Contact items, including custom fields, into an Access 2002 database. Also includes a function that generates an Access report listing all the fields in the tables in the current Access database. Uses Dmitry Streblechenko's Redemption Library to avoid the Object Model Guardian pop-ups. code46.zip

241 KB

 

 

59 VBS, VBA Importing Contacts from a Text File into Outlook

Updated

9/26/2000

Shows how to import contacts from a comma-delimited text file into an Outlook Contacts folder, using Access as an intermediary code59.zip

240 KB


bullet

Outlook  03right.jpg (1880 bytes)  Access 03right.jpg (1880 bytes)  Word

No. VB Dialect Title
Date Last Uploaded
Summary File to Download
50 VBS and VBA Exporting Contacts to a Mail Merge Document

5/18/1998

Demonstrates exporting contacts in a particular folder to a Word mail merge document of the Form Letters type (one letter per page), with a choice of using an Access table or a text file as the data source for the mail merge document. code50.zip

93 KB


bullet

Outlook  03right.jpg (1880 bytes)  Excel

No. VB Dialect Title
Date Last Uploaded
Summary File to Download
41 VBA Exporting Contact Items to an Excel Worksheet

Updated

5-Sep-2007

Uses an Outlook VBA procedure to export all the contacts from the selected  Contacts folder into an Excel worksheet called Contacts.xls, where each contact's information creates a new row.  A few built-in fields are exported, plus one custom field, to demonstrate the syntax.  Requires Office 2000 or higher. code41.zip

53 KB

47 VBA Exporting Mail Items to an Excel Worksheet

5-Sep-2007

Uses a VBA procedure to export all the mail messages from the selected Contacts folder into an Excel worksheet called Messages.xls, where each message's information creates a new row.  A few built-in fields are exported, plus one custom field, to demonstrate the syntax.  Requires Office 2000 or higher code47.zip

82 KB

 

58 VBS and VBA Exporting Calendar Items to Excel

Updated

20-Jul-2008

Shows how to export Calendar items to an Excel worksheet.  For Office 97/Outlook 98, an Outlook form with VBS code is used; for Office 2000 or higher, an Outlook VBA procedure is used, and you can specify a date range for filtering the appointments. code58.zip

111 KB


bullet

Outlook  03right.jpg (1880 bytes)  Word

No. VB Dialect Title
Date Last Uploaded
Summary File to Download
6 VBS Select a Word template for merging Outlook contact data to a letter

Updated

9/26/2000

This sample includes an Outlook form and a Word template.  It demonstrates use of a Windows CommonDialog control to open a dialog where you can choose a Word template to use for creating a new letter using business or home name/address data from the current contact. code6.zip

112 KB

13 VBA Pull Outlook contact data into Word letters

3/10/1998

This sample includes two Word 97 templates with AutoNew macros that pick up basic contact information from the currently open Contact item in Outlook, and paste it to either bookmarks or custom doc properties in the new Word document created from the template. Includes a discussion of the relative merits of bookmarks and custom doc properties. code13.zip

60 KB

 

29 VBA & VBS Time & Expense Billing Application, Version 2

Updated

27-Jan-2011

A  custom Outlook Journal template and several Word templates are used to create time and expense slips and generate attractively formatted Word invoices.  Version 3 has separate versions of files for each Office version from 97 through 2010, plus Excel worksheets for importing slip data to other applications.  For Office 2003 and 2010, there are also statements, and options for creating invoices with times to the nearest 1/10 or 1/4 hour. code29.zip

6,347 KB

 

 

30 VBS Creating Word Documents for Multiple Contacts

Updated

5/3/2001

Displays contacts from a selected folder or an Access table in a multi-select listbox on an Outlook form, and generates Word documents for the selected contacts. Works in both Office 97 (with Outlook 98) and Office 2000.  

code30.zip

247 KB

31 VBA Creating Word Documents for Multiple Contacts with the Selection Object

Updated

7/6/2001

Uses the Outlook 2000 Selection object to select multiple contacts for Word letters or labels.   Works only in Office 2000 or higher.  

code31.zip

168 KB

32 VBA Creating a Word Document with Data from an Outlook Mail Message

3/25/2002

Illustrates two methods of getting data from an open Outlook mail message and putting it into a Word document; one uses code on a Word template’s Document_New event and the other is an Outlook 2000 VBA procedure.  

code32.zip

134 KB

33 VBA Selecting Outlook Contacts for Word Letters from a Multi-Select Listbox

7/16/2000

A multi-select listbox on a Word UserForm popped up from a template’s New event lets users select contacts for a letter; letter text is picked up from the form. The TypeText method is used to write data to the letters. Works with both Office 97 and Office 2000. code33.zip

139 KB

34 VBS Exporting Outlook Contact Info to Word Letters

Updated

6/24/2000

This code sample exports contact name and address data from an Outlook custom contact item to a choice of three Word templates, using either a combo box or an option group. The Outlook data is stored in custom doc properties in the Word document.  The CommonDialog control is not used on the Outlook form. code34.zip

44 KB

39 VBS Exporting Outlook Contact Info to Word Letters

Updated

9/26/2000

This sample has an Outlook form with three command buttons that use three different methods (DocProps, Bookmarks and TypeText) to insert information from an Outlook contact form to a new Word doc based on a template, using VBScript from Outlook. Three Word templates are included. (The VBScript code includes one custom field, to show the syntax for referencing Outlook custom fields.) code39.zip

79 KB

40 VBA Printing Labels with Outlook Contact Info from Word

Updated

9/26/2000

A Word template uses VBA code in its New event procedure to pull in all the contacts in an Outlook folder of your choice, putting one address in each cell of a table sized to print on Avery #5160 or #5162 address labels, using the Add method of the Items collection to iterate through the contacts in the folder, creating sheets of address labels for all the contacts in the folder. code40.zip

115 KB

56 VBA Getting a Contact Address from the Address Book

7/27/1998

Shows how to pop up the Address Book from a Word template's AutoNew procedure; information from several fields of the selected address are stored in the document's custom doc properties, and displayed in fields on the document. code56.zip

58 KB


bullet

Word  03right.jpg (1880 bytes)  Access

No. VB Dialect Title
Date Last Uploaded
Summary File to Download
8 VBA Exporting Word Tables to Access Tables

Updated

12/13/2001

Demonstrates exporting data in a series of Word tables in a Word document to two Access tables, linked one-to-many. code8.zip

143 KB