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

How do I write a macro to close all open images without user prompt?

All --

I would like to create a mechanism to close all open images (modified or not) without prompting the user.

I have written the macro below based on information in prior posts but there seems there is a problem with the image that appears to be active not being the active image.

Can someone please help me resolve the issue with this macro?

Thanks.

-- Matt

--------------------------------------

    Sub CloseAllOpenImages

        'Determine the number of open documents
        Dim MyNumberOfDocuments
        MyNumberOfDocuments = ThisApplication.Documents.Values.Count

        'Loop through the open documents
        Dim MyI As Integer
        For MyI = 1 To MyNumberOfDocuments

                'Close the active image
                ThisApplication.ActiveImage.Modified = False
                ThisApplication.ActiveImage.Close

            Next

    End Sub
 
---------------------------------------

Best Answers

  • Answer ✓
    Matt,

    Here is an even simpler macro.

    Pierre

        Public Function Macro1() As SimpleScript
            Macro1 = New SimpleScript
    
            With Application.WindowCommands.CloseAll(Macro1)
                .Run()
            End With
    
        End Function
  • Answer ✓
    Matt,

    There are multiple ways, but here is another simple macro to do that.

    Pierre

        Public Sub CloseAllNoPrompt()
    
            CloseAllForm.ClosingAllAction=CloseAllForm.CloseAllFormAction.actionNoAll
            ThisApplication.Windows.CloseAll()
    
        End Sub
    
  • edited July 2014 Answer ✓

    Hi Matt,

    This is my macro:

      Public Function Close_All_Open_Images_Without_Prompt() As SimpleScript
      Close_All_Open_Images_Without_Prompt = New SimpleScript

      With Application.ApplicationCommands.SetOption(Close_All_Open_Images_Without_Prompt)
       .Section = "Images"
       .Key = "PromptBeforeClosing"
       .Value = False
       .Run()
      End With

      With Application.WindowCommands.CloseAll(Close_All_Open_Images_Without_Prompt)
       .Run()
      End With

      With Application.ApplicationCommands.SetOption(Close_All_Open_Images_Without_Prompt)
       .Section = "Images"
       .Key = "PromptBeforeClosing"
       .Value = True
       .Run()
      End With

     End Function
     

    Also you can disable the prompt in the application options dialog.

Answers

  • Pierre --

    Thank you for the prompt response.

    The macro you provided works perfectly.

    I produce the same macro using

        RECORD MACRO
        +
        CLOSE ALL VIEWS

    but since PREMIER prompted the user (me) about whether to close a modified image, I assumed the prompt would happen when the macro was run.

    That led me to trying to close the open images

    Thanks for the assistance.

    -- Matt
  • Pierre --

    Yesterday when I tested your SOFTWARE / SOLUTION, I "modified" the some of my open images by making a measurement on them.  They showed an asterisk in the TITLE BLOCK but closed with out prompt using the
            With Application.WindowCommands.CloseAll(Macro1)
                .Run()
            End With
    Today I changed the calibration of one of the open images and a USER PROMPT was presented by the the CLOSEALL.

    For this application, the software needs to be able to close all images without prompting the user.  Can the macro you provided be modified to do this or can you resolve the issue that kept my macro from doing this?

    Thanks.

    -- Matt
  • Pierre and Nikita --

    Thank you for your replies.

    I have integrated the code the Pierre provided into the app but I expect that there are some nuggets of gold in the code that Nikita provided that will work their way into the app also.

    I thought I'd get to answer YES to both of your answers but that does not look to be the case. :-(

    Thanks again.

    -- Matt
Sign In or Register to comment.