How to close window forcefully
Hi Specialist:
I try to close window forcefully without considering the prompt window of save or not. However, the macro below can not realize this. Could you please direct me how to revise? Thank you.
I try to close window forcefully without considering the prompt window of save or not. However, the macro below can not realize this. Could you please direct me how to revise? Thank you.
Tagged:
0
Answers
I have solved it, just share the code. Thank you.
_windows = ThisApplication.Windows _windows.CloseAll(True)
CloseAllForm.ClosingAllAction=CloseAllForm.CloseAllFormAction.actionNoAll
ThisApplication.Windows.CloseAll()
Thanks for your code, it also works.
https://forums.mediacy.com/discussion/258/how-do-i-write-a-macro-to-close-all-open-images-without-user-prompt
'Determine the number of open documents
Dim MyNumberOfDocuments
MyNumberOfDocuments = ThisApplication.Documents.Values.Count
'If there are any images open
If ( MyNumberOfDocuments > 0 ) Then
'Then
'Give the user an appropriate prompt
If (MsgBox _
( _
"There are images open within IMAGE-PRO PREMIER." & vbLf & vbLf & _
"This program is designed to work with only its images open." & vbLf & vbLf & _
"Please press YES to CLOSE ALL IMAGES or press NO to leave the images open.", _
vbYesNo, _
"'textBox_WorkingFolder_DoubleClick' says . . ." _
) = vbYes) Then
'Close all open images without prompting user
CloseAllForm.ClosingAllAction=CloseAllForm.CloseAllFormAction.actionNoAll
ThisApplication.Windows.CloseAll()
End If
End If
Thanks for your solution, I have read a lot of posts sent by you and it helped a lot.