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


How can I prompt a user dialog for files selection like API function GetOpenFilename?
I want the use to select some images but not to open them... just to get an array list with their filenames.
Mediacy.Controls.Common.Vb.MCFileOpenDialog raises an error when select more than one file.


  • SteliosGietos,

    If you want to show Open file dialog, then the standard OpenImage command will work, just leave FileNames property empty and the a prompt will be shown:

        Public Function PromptForImage() As SimpleScript
            PromptForImage = New SimpleScript
            Dim docList1 = New List(1), doc1
            With Application.DocumentCommands.OpenImage(PromptForImage)
                .Filenames = Nothing
                .BestFitMode = True
                .GroupRelatedFiles = False
            End With
            With Application.DocumentCommands.Activate(PromptForImage)
                .Run(docList1(0), doc1)
            End With
        End Function

    If you want to enumerate files in a folder and get names, then you can use standard .NET functions, such as EnumerateFiles:

        Public Sub GetListOfFiles
            Dim folder As String="D:\Images" 'change to your own folder
            Dim files=System.IO.Directory.EnumerateFiles(folder,"*.tif")
            For Each file As String In files
                Debug.Print (file)
        End Sub


  • Thanks Yuri...
    Your examples helped me a lot.
Sign In or Register to comment.