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

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Help with obj.SaveAs API script

ptc-5341196
1-Newbie

Help with obj.SaveAs API script

I've developed an application using an embedded MathCAD worksheet in Excel. The macro passes an array of input data into MathCAD and retrieves an array of calculation results. I would like to be able to save the embedded MathCAD file as a stand alone .xmcd file using a macro. I'm very confused about the format of the SaveAs function since the Developer's guide doesn't provide an example that uses it. Can anyone please provide some format/info/example on its use? Thank you very much.

My code is:

Sub Save_MathCAD_Object()

' Define variables and types

Dim MathcadObject As OLEObject

Dim file_loc As String

' Unprotect worksheet

Sheets("Embedded_MathCAD_file").Unprotect Password:="SDC_224"

file_loc = Sheets("Embedded_MathCAD_file").Cells(2, 1)

' Set a reference to the Mathcad object on the sheet

Set MathcadObject = Sheets("Embedded_MathCAD_file").OLEObjects(1)

' Save MathCAD file

MathcadObject.SaveAs "C:\Users\sdcollins\Desktop\MathCADFiles\Test.xcmd", 0

' Protect worksheet

Sheets("Embedded_MathCAD_file").Protect Password:="SDC_224"

End Sub

0 REPLIES 0
Top Tags