Hi,
If understand you correctly, you want to close the 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
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
Hi,
Thank you for the feedback.
Happy to hear your issue were solved. 😊
Regards,
Berndt
Can't find what you're looking for? Ask the community or share your knowledge.