DOCUMENT:Q130728 02-FEB-2002 [foxpro] TITLE :OLE Controls Available in Visual FoxPro PRODUCT :Microsoft FoxPro PROD/VER::3.0 OPER/SYS: KEYWORDS:kbcode kbvfp300 ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual FoxPro for Windows, version 3.0 ------------------------------------------------------------------------------- SUMMARY ======= The Professional Edition of Visual FoxPro has up to four OLE controls available in .OCX files depending on which Windows platform is being use. This article describes each of those controls and gives tips for using them. OLE controls covered are: - MSCOMM32.OCX for communications - MSMAPI32.OCX for MAPI (Messaging Application Program Interface) - MSOUTL32.OCX for outlining - PICCLP32.OCX for picture clip This article summarizes information available as many smaller help topics about OLE controls in the Visual FoxPro Professional Reference Help file. MORE INFORMATION ================ OLE Controls Overview --------------------- The Visual FoxPro OLE Container control lets you add OLE controls (.OCX files) to your applications. Depending on your Windows platform (Windows version 3.1, Windows for Workgroups, Windows NT, or Windows 95) up to four OLE controls are installed with Visual FoxPro in your WINDOWS\SYSTEM directory. Event, Method, or Property May Apply to OLE Container (Form) or OLE Control --------------------------------------------------------------------------- It's important to note that many events, methods, and properties that need to be set for OLE controls apply to the OLE Container control in which the OLE control is placed rather than directly to the OLE control itself. Others apply directly to the control. For example, the MAPI DownLoadMail property applies directly the MAPI OLE control, but the MAPI DocumentFile property applies to the container that the MAPI OLE object is in. Therefore, these properties for the MAPI OLE control are referenced in this manner: SomeForm.DocumentFile SomeMAPIControl.DownLoadMail Code Sample for OLE Control --------------------------- The following code sample shows how an OLE container can be added to a form and used to modify a Microsoft Excel file from Visual FoxPro: * The following example adds an OLE Container control to a form, and uses * the OleClass and DocumentFile properties to specify Microsoft Excel as * the OLE server and a Microsoft Excel worksheet as the file to edit. * * The DocumentFile property specifies a worksheet named BOOK1.XLS in * the EXCEL directory on drive C. This example will not work if * the file and directory specified in the DocumentFile property do not * exist; It may be necessary to modify the DocumentFile property to * specify an existing directory and worksheet file. * * The DoVerb method is used to activate the worksheet for editing. frmMyForm = CREATEOBJECT('Form') && Create a Form frmMyForm.Closable = .F. && Disable the Control menu box frmMyForm.AddObject('cmdCommand1','cmdMyCmdBtn') && Add command button frmMyForm.AddObject("oleObject","oleExcelObject") && Add OLE object frmMyForm.cmdCommand1.Visible=.T. && Display the Quit command button frmMyForm.oleObject.Visible=.T. && Display the OLE control frmMyForm.oleObject.Height = 50 && Specify OLE control height frmMyForm.Show && Display the Form frmMyForm.oleObject.DoVerb(-1) && -1 for Edit READ EVENTS && Start event processing DEFINE CLASS oleExcelObject as OLEControl OleClass ="Excel.Sheet" && Server name DocumentFile = "C:\EXCEL\BOOK1.XLS" && This file must exist ENDDEFINE DEFINE CLASS cmdMyCmdBtn AS CommandButton && Create command button Caption = '\