Home Image-Pro Automation (Macros, Apps, Reports)

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.




Tagged:

Answers

  • Hi Friends:
               I have solved it, just share the code. Thank you.

          
    Public _windows As McWindows
    _windows = ThisApplication.Windows _windows.CloseAll(True)
  • 2022-02-14-143516

    StanleyH --

    Below is another way to perform a CLOSE ALL IMAGE WINDOWS without a prompt to the USER

    I hope this is helpful.

    -- Matt

    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

                            'CLOSE ALL OPEN IMAGES WITHOUT PROMPTING THE USER
                            CloseAllForm.ClosingAllAction=CloseAllForm.CloseAllFormAction.actionNoAll
                            ThisApplication.Windows.CloseAll()

  • Hi Matt:
               Thanks for your code, it also works.
  • 2022-02-15-093338

    StanleyH --

    Thank you for locating and posting the link to that POST. 

    You might also consider putting your own PROMPT in front of your CLOSE ALL.  Maybe something like what I have used in the past. 

    I hope this is helpful.

    -- Matt

    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

            '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

  • Hi Matt:
                Thanks for your solution, I have read a lot of posts sent by you and it helped a lot.
  • 2022-02-16-122809

    StanleyH --

    Super.

    Thanks.

    -- Matt


Sign In or Register to comment.