OL97: Accessing Data from an Outlook Grid ControlLast reviewed: March 2, 1998Article ID: Q171158 |
The information in this article applies to:
SUMMARYThis article demonstrates how to use Visual Basic for Applications to access data from a Grid control in a Microsoft Outlook 97 item. NOTE: The Grid control is not included with Microsoft Office 97 or Outlook 97. To obtain the Grid control, run Microsoft Visual Basic, version 4.0 or 5.0 setup.
MORE INFORMATION
Create the Form with Grid control
Create the Visual Basic for Applications CodeMicrosoft 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 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 needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. 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/refguide/default.aspThe following code sample demonstrates how to reference a Grid control from any Office program that supports Visual Basic for Applications (VBA). This example generates a random number between one and six, and then assigns that number to the Grid control in an Outlook item. The code then retrieves and displays the value from the Grid control in a message box. With the Untitled form open, run the following code from any Office 97 Application:
Public Sub OlGridExample() '********************************************************************* ' In this example the Grid control is on tab P.2 of the form. ' The form is open, and is not in design mode. '********************************************************************* Set objOutlook = Nothing Set objOutlook = CreateObject("Outlook.Application") Set objNameSpace = objOutlook.GetNamespace("MAPI") Set objInspector = objOutlook.ActiveInspector Set objItem = objInspector.CurrentItem '********************************************************************* ' Reference the Grid control on the modified Form. '********************************************************************* Set Controls = objItem.GetInspector.ModifiedFormPages("P.2").Controls Set ctrlGrid = Controls("Grid1") '********************************************************************* ' Populate the Grid control with data. '********************************************************************* ctrlGrid.Col = 1 ctrlGrid.Row = 0 ctrlGrid.Text = "Test" ctrlGrid.Col = 1 ctrlGrid.Row = 1 ctrlGrid.Text = Int((6 * Rnd) + 1) ' Generate random value ' between 1 and 6. '********************************************************************* ' Retrieve and display the Grid control data in a message box. '********************************************************************* ctrlGrid.Col = 1 ctrlGrid.Row = 0 dataString1 = ctrlGrid.Text ctrlGrid.Col = 1 ctrlGrid.Row = 1 dataString2 = ctrlGrid.Text MsgBox "The value set for " & dataString1 & " is " & dataString2 End Sub REFERENCESFor more information about creating solutions with Microsoft Outlook 97, please see the following articles in the Microsoft Knowledge Base:
Article-ID: Q166368 Title : OL97: How to Get Help Programming with Outlook Article-ID: Q170783 Title : OL97: Q&A: Questions about Customizing or Programming Outlook |
Additional query words: OutSol OutSol97
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |