Results 1 to 6 of 6

Thread: On Error GoTo line... doesn't work. Why?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    Jun 2016
    Posts
    11
    Location

    On Error GoTo line... doesn't work. Why?

    Hi, I have problem with On Error statement

    When I use my code sometimest there is no file that I need (StrFilename2, and StrFilename3) and I need an error statement. First statement works ok (On Error GoTo line1), but second not (On Error GoTo Line2), could you tell me where is problem from this part of my code?
    I will be grateful for your response
    Jan

    If .... 
    code....
    
    Else
    
    On Error GoTo line1        
     UnpackFold = UnzipFold(StrFilename)
            StrFilename2 = UnpackFold & "file.docx"
        
            Open StrFilename2 For Input As #iFile
            Do Until EOF(1)
                Input #1, strTextLine
                Debug.Print "strTextLine : " & "   " & strTextLine
            Loop
            Close #iFile
    line1:
    
    On Error GoTo line2
            StrFilename3 = UnpackFold & "file2.docm"
            Open StrFilename3 For Input As #iFile
            Do Until EOF(1)
                Input #1, strTextLine
                Debug.Print "strTextLine : " & "   " & strTextLine         
            Loop
            Close #iFile
    line2:
            MsgBox "Do not recognize extension"
    End If
    Last edited by Dzony; 07-05-2016 at 08:01 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •