Skip to main content
4-Participant
March 30, 2024
Question

Solving MathCad Sheet from VBA api

  • March 30, 2024
  • 1 reply
  • 904 views

Would anyone have any recommendations on how to improve the code below? I use this function to solve Mathcad sheets from an Excel worksheet (using VBA code). The main hurdle here is to have the script wait until the Mathcad sheet is done calculating before moving on to other tasks. So far, this script seems to work fairly reliably, but it wouldn't surprise me if there's something better out there. 

 

Using Mathcad Prime 9.0

 

 

 

Sub SolveMathCadSheet(mathCadSheet As Ptc_MathcadPrime_Automation.Worksheet)

Dim n As Integer
mathCadSheet.ResumeCalculation
mathCadSheet.Modified = False
mathCadSheet.Synchronize
n = 0
Do While mathCadSheet.Modified = False
 Application.Wait (Now + TimeValue("0:00:01"))
 n = n + 1
 If n > 20 Then Exit Sub 
Loop


End Sub

 

 

 

1 reply

Community Manager
April 5, 2024

Hello @BoyHowdy,

Thank you for your question. 
I’d like to recommend to bring more details and context to your initial inquiry

It also helps to have screenshot(s) to better understand what you are trying to do in your process. 

This will increase your chances to receive meaningful help from other Community members. 

Regards,

Community Moderation Team.