'Mathcad automation in Excel

I would like to automate some computations done via mathcad (v15) within excel. A first solution (that works) is to add a new empty OLE object (mathcad document) and to the select the mathcad file we want to embed. Then it is possible to exchange data with mathcad using VBA.

However I would like to separate the mathcad file and the excel file.

I tried to add an object from a file and to link it (in the insert object dialog, by selecting create from file and link it to file). When I run my macro, I have the following message: "unable to get object property of oleobject class" (or something like this I use french version of Excel).

Here is my piece of code:

Dim MathcadObject As Object

Set wordObj = ActiveSheet.OLEObjects(1)
'wordObj.Activate 'Launches mathcad: the file association is recognized


Set MathcadObject = Worksheets("Feuil1").OLEObjects(1).Object 'fails with error cannot get property value...

Does anyone has any idea on how to solve this?

Bests



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source