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

Open file macro

Hi ,
I need to load a TIF file during the macro execution.
This is the code I use (it works fine)
    Public Function bianco() As SimpleScript
        bianco = New SimpleScript
        Dim docList1 = New List(1), doc1

        With Application.DocumentCommands.Open(bianco)
            .Filenames = New String() {"C:\App_Iec\bianco1.tif"}
            .Run(docList1)
        End With

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

    End Function

Is there possible to intercept any error (eg file not found) without showing error dialog box?
I would like to manage the error internally without stop the macro execution
than yuo
Maurizio

Answers

  • Options
    edited April 2015
    Hi Maurizio,

    You can use try/catch block to handle the error yourself, but it would be easier just to check if the file exists before trying to open it, like this:

        Public Sub bianco2()
            Dim bianco = New SimpleScript
            Dim docList1 = New List(1), doc1
    
            If System.IO.File.Exists("C:\App_Iec\bianco1.tif") Then
                'open the file
                With Application.DocumentCommands.Open(bianco)
                    .Filenames = New String() {"C:\App_Iec\bianco1.tif"}
                    .Run(docList1)
                End With
    
                With Application.DocumentCommands.Activate(bianco)
                    .Run(docList1(0), doc1)
                End With
            Else
                'no file, do something else
                MsgBox("No file")
            End If
        End Sub
    

    Yuri
Sign In or Register to comment.