|
-
Jul 8th, 2005, 08:47 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Open Dialog Error
I get an error when i click cancel on it.
VB Code:
Private Sub Open_Click()
Dim strText$
With CommonDialog1
.Flags = cdlOFNExplorer
.Filter = "Html (*.html)|*.html"
.ShowOpen
Open .FileName For Input As #1
strText = Input(LOF(1), #1)
Text1.Text = strText
Close #1
End With
End Sub
-
Jul 8th, 2005, 09:04 AM
#2
Hyperactive Member
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 
-
Jul 8th, 2005, 09:15 AM
#3
-
Jul 8th, 2005, 10:30 AM
#4
Thread Starter
Hyperactive Member
Re: Open Dialog Error
 Originally Posted by Hack
Add .CancelError = False
didn't work
-
Jul 8th, 2005, 10:33 AM
#5
Re: Open Dialog Error
 Originally Posted by xypherx
didn't work
VB Code:
Private Sub Command1_Click()
With CommonDialog1
.CancelError = False
.Flags = cdlOFNExplorer
.Filter = "Html (*.html)|*.html"
.ShowOpen
End With
End Sub
Works just fine for me.
-
Jul 8th, 2005, 12:25 PM
#6
Thread Starter
Hyperactive Member
Re: Open Dialog Error
 Originally Posted by Hack
VB Code:
Private Sub Command1_Click()
With CommonDialog1
.CancelError = False
.Flags = cdlOFNExplorer
.Filter = "Html (*.html)|*.html"
.ShowOpen
End With
End Sub
Works just fine for me.
tryed it still didnt work
-
Jul 8th, 2005, 12:28 PM
#7
Re: Open Dialog Error
 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.
-
Jul 8th, 2005, 12:34 PM
#8
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??
-
Jul 8th, 2005, 01:00 PM
#9
Thread Starter
Hyperactive Member
Re: Open Dialog Error
VB Code:
Option Explicit
Private Sub open_Click()
Dim strText$
With CommonDialog1
.CancelError = False
.Flags = cdlOFNExplorer
.Filter = "Html (*.html)|*.html"
.ShowOpen
Open .FileName For Input As #1
strText = Input(LOF(1), #1)
Text1.Text = strText
Close #1
End With
End Sub
im getting a variable not defined error
-
Jul 8th, 2005, 01:22 PM
#10
Re: Open Dialog Error
 Originally Posted by xypherx
VB Code:
Option Explicit
Private Sub open_Click()
Dim strText$
With CommonDialog1
.CancelError = False
.Flags = cdlOFNExplorer
.Filter = "Html (*.html)|*.html"
.ShowOpen
Open .FileName For Input As #1
strText = Input(LOF(1), #1)
Text1.Text = strText
Close #1
End With
End Sub
im getting a variable not defined error
What variable? What is highlighted when the error occurs?
-
Jul 8th, 2005, 01:23 PM
#11
Thread Starter
Hyperactive Member
Re: Open Dialog Error
it says open_click()
but i did it right im sure of it its in the menu
-
Jul 8th, 2005, 01:24 PM
#12
Re: Open Dialog Error
Is it in the menu as mnuOpen or Open?
-
Jul 8th, 2005, 01:31 PM
#13
Thread Starter
Hyperactive Member
Re: Open Dialog Error
its fixed but the
VB Code:
Open .FileName For Input As #1
is giving a error for pathname or something like that
-
Jul 8th, 2005, 01:33 PM
#14
Re: Open Dialog Error
 Originally Posted by xypherx
its fixed but the
VB Code:
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?
-
Jul 8th, 2005, 01:37 PM
#15
Thread Starter
Hyperactive Member
Re: Open Dialog Error
it will open its just the .cancelerror = false isnt working for it.
-
Jul 8th, 2005, 01:43 PM
#16
Re: Open Dialog Error
 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.
-
Jul 8th, 2005, 01:44 PM
#17
Thread Starter
Hyperactive Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|