The information in this article applies to:
SUMMARYThis 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 INFORMATIONWith 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, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals 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 needs. If you have limited programming experience, you may want to contact a Microsoft Certified Solution Provider or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Solution Providers, please see the following page on the World Wide Web: http://www.microsoft.com/mcsp/For more information about the support options available from Microsoft, please see the following page on the World Wide Web: http://www.microsoft.com/support/supportnet/overview/overview.aspNOTE: 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.
NOTE: This functionality does not work with VBScript version 3.0 or older
versions of VBScript version 3.1. When using the GetObject function with
these versions, GetObject will launch another instance of the application
instead of using the existing instance. This problem has been fixed in an
update to VBScript 3.1 (VBscript.dll version 3.1.0.2430, file date
12/30/97), which is available for download at:
http://www.microsoft.com/scriptingThe 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.
REFERENCES
For more information on obtaining updated VBScript versions, please see
the following article in the Microsoft Knowledge Base:
Additional query words: OutSol OutSol98
Keywords : kbdta kbdtacode OffVBS OffVBA |
Last Reviewed: November 3, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |