Hi,
I'm having trouble with the Save Box on the CommonDialog. Sure, when I enter a file name and press ok the file is saved and Everything is fine, but when I press cancel I get an invalid filename error. What is up???
Printable View
Hi,
I'm having trouble with the Save Box on the CommonDialog. Sure, when I enter a file name and press ok the file is saved and Everything is fine, but when I press cancel I get an invalid filename error. What is up???
rino...This may or may not be it,, but have you tried turning off the CancelError property of the CommonDialog?
Just a thought.
- Chris
Try something like this: (put this code right after CommonDialog1.ShowOpen Command)
If Err <> 32755 Then and put everything you want to do when user did not press Cancel. It won't do anything when user will press Cancel.
------------------
Visual Basic Programmer (at least I want to be one)
------------------
PolComSoft
You will hear a lot about it.
[This message has been edited by QWERTY (edited 11-16-1999).]
could you give me an exact statment please???
do something like this:
This Should WorkCode:Private Sub Command1_Click()
CommonDialog1.ShowOpen
If Err<>32755 Then
FileToOpen=CommonDialog1.FileName
Else
MsgBox "Cancel Was Pressed"
End If
End Sub
------------------
Visual Basic Programmer (at least I want to be one)
------------------
PolComSoft
You will hear a lot about it.
you could aslo try to do somthing like this:
though I haven't tried it yet.
Private Sub cmdSave_Click()
Dim sFile As String
On Error GoTo NoFile
With cdbLoadSave
.DialogTitle = "save your file"
.Filter = "File(.file)|*.file"
.DefaultExt = ".file"
.CancelError = True
.ShowSave
sFile = .filename
End With
NoFile:
End Sub
name the command button cmdSave and the commondialog cdbLoadSave
hope this helps.
-Lumin
hi again...
if my example is not working you can use the
example that is displayed on the topic below named COMMONDIALOG
-Lumin
Couldn't u just use this to make it work:
Commondailog1.Cancelerror = true
On Error GoTo DoNothing
. . .
. . .
DoNothing:
If Err.Number = cdlCANCEL Then
; do nothing, Cancel button clicked
Else
Msgbox Err.Description
End if
ENd sub
that always works fine for me
yeah probably.. but now you are making thing just easy : )