Mathcad's Automation Interface |
Mathcad's Automation interface provides a mechanism for communicating with Mathcad from within another Windows application, including a custom stand-alone application you write yourself. Using OLE Automation commands, you can:
To use Automation technology, write a program in Visual Basic 5.0 (or higher) or in an application that can serve as an Automation client, such as Microsoft Excel version 5.0 (or higher). The program you write defines and retrieves variables in Mathcad worksheets. The variables defined in and retrieved from Mathcad can be complex scalars, strings, or matrices. Dimensions (units) are not retained.
Mathcad provides two APIs for automation:
The following examples of the scripting API suggest what is possible with Mathcad Automation and could form the basis of expanded projects. They demonstrate the use of the primary features of the IMathcad Application API:
Mathcad 12 and higher support the GetActiveObject COM API function to retrieve a pointer to the Application object of an already running and visible instance of Mathcad. It is used like this:
(Visual C++)
#import "progid:Mathcad.Application"
Mathcad::MathcadApplicationPtr GetMathcadApp()
{
CComPtr< IUnknown > spAppUnk;
//Get the active instance of Mathcad from the ROT.
if ( SUCCEEDED( ::GetActiveObject( __uuidof( Mathcad::Application ), NULL, & spAppUnk) )
{
return ( IUnknown * )spAppUnk;
}
return NULL;
}