Results 1 to 17 of 17

Thread: [RESOLVED] Open Dialog Error

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    348

    Resolved [RESOLVED] Open Dialog Error

    I get an error when i click cancel on it.
    VB Code:
    1. Private Sub Open_Click()
    2. Dim strText$
    3.    
    4.     With CommonDialog1
    5.         .Flags = cdlOFNExplorer
    6.         .Filter = "Html (*.html)|*.html"
    7.         .ShowOpen
    8.         Open .FileName For Input As #1
    9.             strText = Input(LOF(1), #1)
    10.             Text1.Text = strText
    11.         Close #1
    12.     End With
    13. End Sub

  2. #2
    Hyperactive Member wiccaan's Avatar
    Join Date
    Apr 2004
    Location
    127.0.0.1
    Posts
    475

    Re: Open Dialog Error

    Try this, I added an error handle to your code, as well as set x to freefile. It works fine for me.

    Code:
    Private Sub Open_Click()
    On Error GoTo ErrHandle
    Dim strText$
    
        With CommonDialog1
            .Filter = "Html (*.html)|*.html"
            .Flags = cdlOFNExplorer
            .ShowOpen
            
            x = FreeFile
            Open .FileName For Input As x
                Text1.Text = Input(LOF(x), x)
            Close x
        End With
    ErrHandle:
        Exit Sub
    End Sub
    If my post was helpful please rate it

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Open Dialog Error

    Add .CancelError = False

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    348

    Re: Open Dialog Error

    Quote Originally Posted by Hack
    Add .CancelError = False

    didn't work

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Open Dialog Error

    Quote Originally Posted by xypherx
    didn't work
    VB Code:
    1. Private Sub Command1_Click()
    2. With CommonDialog1
    3.     .CancelError = False
    4.     .Flags = cdlOFNExplorer
    5.     .Filter = "Html (*.html)|*.html"
    6.     .ShowOpen
    7. End With
    8. End Sub
    Works just fine for me.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    348

    Re: Open Dialog Error

    Quote Originally Posted by Hack
    VB Code:
    1. Private Sub Command1_Click()
    2. With CommonDialog1
    3.     .CancelError = False
    4.     .Flags = cdlOFNExplorer
    5.     .Filter = "Html (*.html)|*.html"
    6.     .ShowOpen
    7. End With
    8. End Sub
    Works just fine for me.
    tryed it still didnt work

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Open Dialog Error

    Quote Originally Posted by xypherx
    tryed it still didnt work
    You got an error when you hit Cancel????

    I don't know why that is happening, but, since it is then trap for the error and when it happens just issue a Resume Next.

  8. #8
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: Open Dialog Error

    hey xypherx!

    i tried ur code and it worked fine n got no error!!!!

    can u explain what kind of error u r getting??

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    348

    Re: Open Dialog Error

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub open_Click()
    4. Dim strText$
    5. With CommonDialog1
    6.     .CancelError = False
    7.     .Flags = cdlOFNExplorer
    8.     .Filter = "Html (*.html)|*.html"
    9.     .ShowOpen
    10.     Open .FileName For Input As #1
    11.             strText = Input(LOF(1), #1)
    12.             Text1.Text = strText
    13.         Close #1
    14. End With
    15. End Sub

    im getting a variable not defined error

  10. #10
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Open Dialog Error

    Quote Originally Posted by xypherx
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub open_Click()
    4. Dim strText$
    5. With CommonDialog1
    6.     .CancelError = False
    7.     .Flags = cdlOFNExplorer
    8.     .Filter = "Html (*.html)|*.html"
    9.     .ShowOpen
    10.     Open .FileName For Input As #1
    11.             strText = Input(LOF(1), #1)
    12.             Text1.Text = strText
    13.         Close #1
    14. End With
    15. End Sub
    im getting a variable not defined error
    What variable? What is highlighted when the error occurs?

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    348

    Re: Open Dialog Error

    it says open_click()

    but i did it right im sure of it its in the menu

  12. #12
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Open Dialog Error

    Is it in the menu as mnuOpen or Open?

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    348

    Re: Open Dialog Error

    its fixed but the
    VB Code:
    1. Open .FileName For Input As #1

    is giving a error for pathname or something like that

  14. #14
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Open Dialog Error

    Quote Originally Posted by xypherx
    its fixed but the
    VB Code:
    1. Open .FileName For Input As #1

    is giving a error for pathname or something like that
    When you select a file from the CommonDialog and click OK, it should return both the full path and filename. The file you are selecting does exist, right?

  15. #15

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    348

    Re: Open Dialog Error

    it will open its just the .cancelerror = false isnt working for it.

  16. #16
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Open Dialog Error

    Quote Originally Posted by xypherx
    it will open its just the .cancelerror = false isnt working for it.
    Then, as I said before, just error trap it and you will be good to go.

  17. #17

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    348

    Re: Open Dialog Error

    alright thanks

Posting Permissions

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



Click Here to Expand Forum to Full Width