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

How is the best way to create a SEQUENCE from a number of INDIVIDUAL TIF IMAGE FILES?

All --

The following section of code was recorded while opening 6 TIF IMAGES as a SINGLE SEQUENCE.

    Public Function NewMacro() As SimpleScript
        NewMacro = New SimpleScript
        Dim docList1 = New List(1), doc1

        With Application.DocumentCommands.OpenSequence(NewMacro)
            .Filenames = New String() {"C:\GE123\Collage No. 001.tif","C:\GE123\Collage No. 002.tif","C:\GE123\Collage No. 003.tif","C:\GE123\Collage No. 004.tif","C:\GE123\Collage No. 005.tif","C:\GE123\Collage No. 006.tif"}
        End With

        With Application.DocumentCommands.Activate(NewMacro)
            .Run(docList1(0), doc1)
        End With

    End Function
The number of COLLAGE IMAGES in the GE123 FOLDER can vary so this code fragment needs to be changed to allow for this.

The LIST OF FILES in the .FILENAME line is a series of INDIVIDUAL COMPLETE FILE NAMES that is flanked by quote marks and separated with commas so I don't know how to have the program create a properly formatted list to feed to the OPEN SEQUENCE COMMAND.

I can use code like

    F = Dir("*.*")
    While F <> ""
        Debug.Print F
        F = Dir()

to find all of the FILE NAMES but I don't know how to build the list and pass it to the OPEN SEQUENCE COMMAND.

Can someone please point me in the right direction.


-- Matt

Best Answer

  • Accepted Answer

    Here is a macro to do that.


        Public Function OpenAsSequence() As SimpleScript
            OpenAsSequence = New SimpleScript
            Dim docList1 = New List(1), doc1
            ' User Code
            Dim files() As String
            With Automate.ScriptingCommands.CodeCommand(OpenAsSequence)
                If .Run() Then
                    ' User Code Here
                    files = system.IO.Directory.GetFiles(ThisApplication.Path(mcPathType.mcptSampleImages) & "HDR")
                End If
            End With
            With Application.DocumentCommands.OpenSequence(OpenAsSequence)
                .Filenames = files
            End With
            With Application.DocumentCommands.Activate(OpenAsSequence)
                .Run(docList1(0), doc1)
            End With
        End Function


  • Pierre --

    Thank you for the EXAMPLE CODE.

    I'll wire it in and give you FEEDBACK ASAP.

    Thanks again.

    -- Matt

  • Pierre --

    Thank you for the EXAMPLE CODE.

    I massaged it into the following SUBROUTINE that works exactly as I need.

    Thanks again.

    -- Matt

        Private Sub button_CreateCollageSequence_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles button_CreateCollageSequence.Click
            'Declare local variables
            Dim MyDocList1 = New List(1)
            Dim MyFiles() As String
            'Close all open images without prompting user
            'Create a list of the TIF FILES in the NAMED FOLDER
            MyFiles = _
            'If TIF FILES were found
            If ( UBound (MyFiles) >= 0 ) _
                    'Open the TIF IMAGES as a SEQUENCE
                    With Application.DocumentCommands.OpenSequence(Nothing)
                        .Filenames = MyFiles
                    End With
                End If
        End Sub

Sign In or Register to comment.