Quote Originally Posted by Dzony View Post
Hi Paul
I have read that I can't use error handling blocks like I did ( http://www.cpearson.com/excel/errorhandling.htm ) so I have to figure out how to do it in other way.
Thank you for help.
Jan
I'd be interested in why you believe that you can't use error handling like that

Was there a specific reference in Chip's link?


Not knowing what your overall logic flow is, but maybe something like this

Option Explicit
Sub test()
    Dim StrFilename2 As String, StrFilename3 As String, UnpackFold As String
    Dim iFile As Long
    Dim strTextLine As String
    
    If 1 = 2 Then
        MsgBox "Nope"
         
    Else
         '    UnpackFold = UnzipFold(StrFilename)
        UnpackFold = "Something"
        StrFilename2 = UnpackFold & "file.docx"
         
        On Error GoTo line1
        iFile = FreeFile
        Open StrFilename2 For Input As #iFile
        Do Until EOF(iFile)
            Input #iFile, strTextLine
            Debug.Print "strTextLine : " & "   " & strTextLine
        Loop
        Close #iFile
        GoTo lbl_Exit
         
line1:
        StrFilename3 = UnpackFold & "file2.docm"
        iFile = FreeFile
         
        On Error GoTo line2
        Open StrFilename3 For Input As #iFile
        Do Until EOF(iFile)
            Input #iFile, strTextLine
            Debug.Print "strTextLine : " & "   " & strTextLine
        Loop
        Close #iFile
        GoTo lbl_Exit
line2:
        MsgBox "Do not recognize extension"
    End If

lbl_Exit:
        On Error GoTo 0
End Sub
It's a bit (a lot) spaghetti-ish with the GoTo's so there's better ways to structure it if we understood the logic and the goal