cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

OLE to load a .MCD file

ptc-4348743
1-Visitor

OLE to load a .MCD file

Our customer gave us an MCD file and wants us to be able to run it via a C++ interface. Running/Linking an automation interface is something we do a lot of, so no biggie there. BUT. This code throws an exception when trying to load the MCD file: (Sorry for he TABLE format. I cannot seem to get it to allow pasting code normally)


IMathcadApplication* McApp;

IMathcadWorksheets* McWorksheets;

IMathcadWorksheet* McWorksheet;

CoInitialize(NULL);// Initialize the COM library

HRESULT hr=CoCreateInstance(CLSID_App, NULL,








CLSCTX_LOCAL_SERVER,








IID_IMathcadApplication,








(LPVOID*)&McApp);

if (!SUCCEEDED(hr)) {


MessageDlg("Unable to create a MathCad Application object",mtError, TMsgDlgButtons() << mbOK, 0);


return ;

}

McApp->Visible=true;

McWorksheets=McApp->Worksheets;

McWorksheet=McWorksheets->Open(L"c:\\KVD_FILE.mcd");

McApp->Release();

Everything works fine until the Open command. Can someone point me to examples of VB, Java, or C++ code that shows how to load a MCD file? And if it is in the callaboratory, can some PLEASE tell me how to get to it. I have never found the callaboratory.

Thanks, Brian

8 REPLIES 8

The Collaboratory is gone!

This is the replacement for it, so I suspect someone (Mr. Jackson?!?) is crafting a reply as I type.

I did not see your statement that you have Mathcad installed on the computer that you are using. Lack of Mathcad (or a sufficiently new version of it) may be part of your problem.

The Collaboratory is gone!

Yes, which is unfortunate. The search on these forums seems to me to be very poor. There are several threads with examples, but even after 15 minutes of messing around I could only find one of them

No wonder I couldn't find it . Yes, I have Mathcad 15 currently installed. I believe our customer is using the same version, but could be using mathcad 14.

Brian Dumas wrote:

No wonder I couldn't find it . Yes, I have Mathcad 15 currently installed. I believe our customer is using the same version, but could be using mathcad 14.

Both version 14 and 15 typically want to write xmcd files, so I'm not sure about the file version. Version 15 should read any mcd file (I've been told.)

Okay, you shot down my simple theory; now you need a VB wizard! (That ain't me!!)

Good luck!

Try to look in "Mathcad Help" (key F1) at section "External Files and Applications" -> "OLE Automation" and further in the text choose the reference on "Developer's Reference".

RichardJ
19-Tanzanite
(To:ptc-4348743)

I posted a small VBA example in this thread:

http://communities.ptc.com/message/161939#161939

Ahh!

Gandalf speaks!

Gandalf speaks!

Sorry, but I don't own a pointy hat

Announcements

Top Tags