Open file macro
                    Hi ,
I need to load a TIF file during the macro execution.
This is the code I use (it works fine)
                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                0
            Answers
- 
            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
Yuri0 
Categories
- All Categories
 - 961 Image-Pro v9 and higher
 - 9 Image-Pro FAQs
 - 18 Image-Pro Download & Install
 - 448 Image-Pro General Discussions
 - 486 Image-Pro Automation (Macros, Apps, Reports)
 - 20 AutoQuant Deconvolution
 - 2 AutoQuant Download & Install
 - 18 AutoQuant General Discussions
 - 195 Image-Pro Plus v7 and lower
 - 3 Image-Pro Plus Download & Install
 - 106 Image-Pro Plus General Discussions
 - 86 Image-Pro Plus Automation with Macros
 - 19 Legacy Products
 - 16 Image-Pro Premier 3D General Discussions
 - 26 Image-Pro Insight General Discussions
 
