Using Mathcad’s OLE Automation Interfaces

Mathad’s OLE Automation interface provides a mechanism for communicating with Mathcad from within another Windows application. Using OLE Automation, you can send data to Mathcad from another application, use Mathcad to perform calculations or other data manipulations, and send results back to the other application. In Mathcad 5 and 6, this kind of communication was carried out using DDE. In Mathcad 7, DDE has been replaced with OLE Automation.

To use OLE Automation technology, you must write a program in Visual Basic 5.0 or in an application that can serve as an OLE Automation client (check with the application’s documentation to find out whether it is an OLE Automation client). The program defines and retrieves variables in Mathcad Document OLE objects. The variables being defined in Mathcad must be named in0, in1, in2, etc. The variables being retrieved from Mathcad must be called out0, out1, out2, etc.

Mathcad Document Object Model

Mathcad 7.02 Document object exposes four automation methods:

GetComplex(BSTR Name, 
           VARIANT* RealPart, 
           VARIANT* ImagPart)	Retrieves complex data (real and imaginary parts) from Mathcad variable Name.	
SetComplex(BSTR Name, 
           VARIANT RealPart, 
           VARIANT ImagPart)	Assigns complex data (real and imaginary parts) to Mathcad variable Name.	
Recalculate()	Recalculates the Mathcad document.	
SaveAs(BSTR Name)	Saves the Mathcad document as a file whose path is given by the string Name.	

The example in this folder illustrates how you can use these methods to communicate with a Mathcad document object using Excel’s VBA environment.

The example in the Doughnut folder contains a Visual Basic 5 project illustrating how to incorporate a Mathcad OLE object into a self-contained Windows application.

For more detailed overview of using Mathcad as an OLE Automation Server please check out the Mathcad 7 Usage Notes on the Web at http://www.mathsoft.com/support/mcad7/usage/.

(10/27/97)