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

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

1292909313
Enthusiast Enthusiast
1,085 Views
5 Replies
Message 1 of 6

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

1292909313
Enthusiast
Enthusiast

1292909313_0-1718163011456.png

 

0 Likes
Accepted solutions (1)
1,086 Views
5 Replies
Replies (5)
Message 2 of 6

bernor_mf
Advisor
Advisor

@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.)
0 Likes
Message 3 of 6

1292909313
Enthusiast
Enthusiast

Sorry, I want to close this window

0 Likes
Message 4 of 6

bernor_mf
Advisor
Advisor
Accepted solution

@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.)
0 Likes
Message 5 of 6

1292909313
Enthusiast
Enthusiast

Thank you very much, my problem has been solved

0 Likes
Message 6 of 6

bernor_mf
Advisor
Advisor

@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.)
0 Likes