Moldflow Insight Forum
Welcome to Autodesk’s Moldflow Insight Forums. Share your knowledge, ask questions, and explore popular Moldflow Insight topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

I want to use a script to close the page below, how to write this script

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
1292909313
271 Views, 5 Replies

I want to use a script to close the page below, how to write this script

1292909313_0-1718163011456.png

 

5 REPLIES 5
Message 2 of 6
bernor_mf
in reply to: 1292909313

@1292909313 

Hi,

If understand you correctly, you want to close the study.

This example closes the active study.
 

 

SetLocale("en-us")
Dim SynergyGetter, Synergy
On Error Resume Next
Set SynergyGetter = GetObject(CreateObject("WScript.Shell").ExpandEnvironmentStrings("%SAInstance%"))
On Error GoTo 0
If (Not IsEmpty(SynergyGetter)) Then
	Set Synergy = SynergyGetter.GetSASynergy
Else
	Set Synergy = CreateObject("synergy.Synergy")
End If
Synergy.SetUnits "Metric"

Set StudyDoc = Synergy.StudyDoc()
StudyDoc.Close

 

 

If to close more open studies, you need to loop the command.

If you get an error, it means no study open, and you need error handling.

 

Hope this helps.

Regards,

Berndt

( If my comments are accepted, provide "Kudos" as appreciation. If your request is answered/resolved, please click the "Accept as Solution" button. Thanks.)
Message 3 of 6
1292909313
in reply to: 1292909313

Sorry, I want to close this window

Message 4 of 6
bernor_mf
in reply to: 1292909313

@1292909313 

Hi,
First, if changes has been made to study, it should be saved.
Otherwise a dialog will appear "Save changes to study_name?".

Code:

Set StudyDoc = Synergy.StudyDoc()
StudyDoc.Save

Might need to add a wait for save to complet such as:
WScript.Sleep 3000 '* in ms, so a wait of 3s

 

You are using Autodesk Moldflow Insight 2021.1 , and to close the window:

'* Closes all windows with title
Dim oShell
Set oShell = WScript.CreateObject ("WScript.Shell")

'* You are using Autodesk Moldflow Insight 2021.1
oShell.Run "taskkill /fi ""WINDOWTITLE eq Autodesk Moldflow Insight 2021.1""",0,False

 

Hope this helps.

Regards,

Berndt

( If my comments are accepted, provide "Kudos" as appreciation. If your request is answered/resolved, please click the "Accept as Solution" button. Thanks.)
Message 5 of 6
1292909313
in reply to: 1292909313

Thank you very much, my problem has been solved

Message 6 of 6
bernor_mf
in reply to: 1292909313

@1292909313 

Hi,

Thank you for the feedback.

Happy to hear your issue were solved. 😊

Regards,

Berndt

( If my comments are accepted, provide "Kudos" as appreciation. If your request is answered/resolved, please click the "Accept as Solution" button. Thanks.)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report