Article ID: 182364 - Last Review: August 27, 2007 - Revision: 2.3 OL98: Programmatically Accessing Office Form DocumentsThis article was previously published under Q182364 On This PageSUMMARY
This article provides an overview of how you can use Microsoft Visual Basic
Scripting Edition (VBScript) or Microsoft Visual Basic for Applications to
programmatically access Office components that are embedded in a Microsoft
Outlook 98 Office Form.
MORE INFORMATION
With Outlook, you can create an Office Form that includes an embedded
Word document, Excel workbook, Excel chart, or PowerPoint presentation. You
typically would use these types of custom Outlook forms as part of a
solution that routes Office documents or shares (posts) Office documents in
a public folder.
Steps to Create an Office FormTo create an Office form follow these steps:
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. NOTE: Because each custom solution has different requirements in order to achieve the desired end result, the methods outlined below are offered as a starting point for achieving the end result, and should be implemented in a way that best suits the solution's needs. Using Events From Embedded ObjectsWhen using Office Forms to create a custom solution, you may want to have Visual Basic for Applications code in the embedded object automatically run. An example of this is having code automatically calculate dates based on today's date and insert those calculated dates into an embedded Excel spreadsheet. To implement this, you create a Workbook_Open() event procedure in the embedded spreadsheet and use Visual Basic for Applications code to calculate the dates. Because the Workbook_Open() procedure is run automatically when the Office Form opens, the code will execute every time you open the Office Form.NOTE: Word will not execute any auto macros or procedures (typically AutoOpen or Document_Open) when a document is embedded in another program, or container. You can, however, place a CommandButton on the Word document object and create a click event procedure for the CommandButton. The user will have to click the button to run the Visual Basic for Applications code in the Word document. If this workaround is not appropriate for your solution, you can use the GetObject method described below to automate the Word document from VBScript. Create an Auto Event for an Excel SpreadsheetTo create an auto event for an Excel spreadsheet use these steps:
Using GetObject to Automate an Embedded ObjectThere may be circumstances where you want to use VBScript to put information into the embedded object or set some attributes of the object. An example of this is creating an Item_Open event in VBScript that automatically inserts a list of your contacts and their addresses into a Word Office Form document.You can use the VBScript version 2.0 GetObject method to access the embedded Office documents. The following sample VBScript 2.0 code will automatically insert "This is from VBScript!" into the embedded Word document in a Word Office Form. Because the code is in an Item_Open event, the code runs automatically when the Office Form item opens. The following table lists various objects that you can use with the GetObject method to access embedded objects. Once you have a reference to the object, consult the object model documentation for that program to manipulate that type of object.
Form Type Object Name*
----------------------- -----------------------------------------
Word document Word.Application or Word.Document
Excel spreadsheet Excel.Application or Excel.Sheet
Excel chart Excel.Application or Excel.Chart
PowerPoint presentation PowerPoint.Application or PowerPoint.Show
* The object you choose depends on which methods and properties
of the application's object model you need to use.
REFERENCES
For more information on obtaining updated VBScript versions, please see
the following article in the Microsoft Knowledge Base:
182446 (http://support.microsoft.com/kb/182446/EN-US/ ) OL98: General Information About Using VBScript With Outlook For more information about creating solutions with Microsoft Outlook 98, please see the following articles in the Microsoft Knowledge Base: 180826 (http://support.microsoft.com/kb/180826/EN-US/ ) OL98: Resources for Custom Forms and Programming 182349 (http://support.microsoft.com/kb/182349/EN-US/ ) OL98: Questions About Custom Forms and Outlook Solutions APPLIES TO
| Article Translations
|

Back to the top
