Skip to main content
15-Moonstone
January 26, 2022
Solved

Open Run Save and Close Mathcad Prime automatically step by  step

  • January 26, 2022
  • 1 reply
  • 5833 views

Dear all

I don't know any code or any Languages only Mathcad Prime.

Please help me my question below. My purpose is to get Platform that can order Mathcad prime sheet Open Run Save and Close automatically step by  step to get Text File without open and run manually that it hard to do with many sheets. And I also attach relevant file as below

Best regards 

SPRstructure

Question.png

 

Best answer by terryhendicott

Hi,

 

You asked:=

"Can you do every step after open and run, close and save automatically  and then next step do the same and then message appear to "Message: Complete All"? and then click "OK" go to result"

 

To save the files add the three following lines after the lines like "txtStep1.Text = Stage 1 OK" in each of four instances.

 

Delay(0.5)
worksheet.Save()
worksheet.Close(0)

 

Add the delay function at the top

 

Sub Delay( seconds )
    Dim wshShell, strCmd
    Set wshShell = CreateObject( "WScript.Shell" )
    strCmd = wshShell.ExpandEnvironmentStrings( "%COMSPEC% /C (TIMEOUT.EXE /T " & seconds & " /NOBREAK)" )
    wshShell.Run strCmd, 0, 1
    Set wshShell = Nothing
End Sub

 

This has been done in enclosed file.

1 reply

21-Topaz II
January 26, 2022

Hi,

"I don't know any code or any Languages only Mathcad Prime."

Start with the example provided in the Prime help.

Example shows how to open and close Mathcad worksheets.

Capture.JPG

Capture2.JPG

Cheers

Terry

21-Topaz II
January 27, 2022

Hi,

 

"I don't know any code or any Languages only Mathcad Prime."

A huge learning curve is ahead.  A language needs to be chosen.

 

Either 1, 2, 3, or 4 is possible

 

1:=

An integrated development environment "IDE" is useful to program code in.

It is possible to design a form interface in this IDE

Microsoft releases a community version of its Visual Studio IDE that is free.

Language choice is C++, C#, Visual Basic.

 

https://visualstudio.microsoft.com/downloads/

Community
Powerful IDE, free for students, open-source contributors, and individuals

Free download

 

This covers examples 1 to 4 in Mathcad Help

 

2:=

Visual Basic for Applications "VBA" can be used to both create the form and develop coding in macros associated with Microsoft Office applications like Word, Excel, Access etc

There is no example in Mathcad help but Example 3 and 4 are close.

 

3:=

A free IDE for java coding is called Eclipse

It is available at

https://www.eclipse.org/downloads/packages/

Eclipse IDE for Java Developers

The essential tools for any Java developer, including a Java IDE, a Git client, XML Editor, Maven and Gradle integration

 

This covers example 5 and 9 in Mathcad help

 

4:=

With nothing but a text editor you can enter VBScript and can create a html interface.

 

This covers example 8 in Mathcad help.

 

Good Luck

Cheers

Terry

Capture.JPG

 

 

21-Topaz II
January 27, 2022

Hi

Text files should end in an extension.  I have added *.txt to all relevant files.

The problem is distilled into the simplest form with a single visual basic script that sends messages to windows.

Enclosed zip file contains all the relevant files.

Capture.JPG.

Start from Prime file "Input Worksheet", from there you  can ctrl+click on the "Run" link

Capture2.JPG

Capture3.JPG

Watch the messages on screen

 

Cheers

Terry