Hi

The problem is when I have open the common dialog
and press the cancel button I got error code 32755
say that I have pressed the cancel button and i halts

On Error GoTo MnuNamnD_click_exit

With dlgDemo
.CancelError = True
.InitDir = mstrLastDir
.Flags = cdlOFNHideReadOnly
.fileName = .FileTitle '""
.Filter = "TextFiles *.txt|*.txt"
.ShowOpen                          ' here it stops when cancel is pressed
StrFileToOpen = .fileName
namn = .FileTitle

End With

On Error GoTo MnuNamnD_click_error

IntDemoFileNbr = FreeFile
Open StrFileToOpen For Binary Access Read As #IntDemoFileNbr
StrBuffer = Input(LOF(IntDemoFileNbr), IntDemoFileNbr)
TxtTestFile.Text = StrBuffer

Close #IntDemoFileNbr

mstrLastDir = Left$(StrFileToOpen, InStrRev(StrFileToOpen, "\") - 1)
Label14.Visible = False
Label16.Visible = True
Label16.Caption = "Fil :" & " " & namn
Exit Sub

MnuNamnD_click_error:
MsgBox " Ett Fel inträffade"

MnuNamnD_click_exit:


TxtTestFile.Visible = False
LstData.Visible = True
AvbTxt.Visible = False
SparaTxt.Visible = False

Any one that can help me with tthis PLEASE:

Lenny

Recommended Answers

All 4 Replies

.CancelError = True

In line 4, Set CancelError to False.

.CancelError = False

Jx Man hi

I have tried that to but now it stops at line 18
with follow error path/file accsess error 75

I have tried that to but now it stops at line 18
with follow error path/file accsess error 75

It happen because when you press a cancel button there are no filename of text file to return.
Filename needed in line 18 to read the file.
So you must to handling it with check if there is no path from dialog box.

If strfileopen <> "" Then 'so this line will execute if path is available
    IntDemoFileNbr = FreeFile
    Open StrFileToOpen For Binary Access Read As #IntDemoFileNbr
    StrBuffer = Input(LOF(IntDemoFileNbr), IntDemoFileNbr)
    TxtTestFile.Text = StrBuffer

    Close #IntDemoFileNbr

    mstrLastDir = Left$(StrFileToOpen, InStrRev(StrFileToOpen, "\") - 1)
End If

also the use of On Error Go To statement is a bad thing.

Thank's all for help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.