Click to See Complete Forum and Search --> : Problem with the Save DialogBox??? - Please help
rino_2
Nov 16th, 1999, 01:54 AM
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???
chrisjk
Nov 16th, 1999, 02:14 AM
rino...This may or may not be it,, but have you tried turning off the CancelError property of the CommonDialog?
Just a thought.
- Chris
QWERTY
Nov 16th, 1999, 02:19 AM
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).]
rino_2
Nov 16th, 1999, 03:11 AM
could you give me an exact statment please???
QWERTY
Nov 16th, 1999, 04:57 AM
do something like this:
Private Sub Command1_Click()
CommonDialog1.ShowOpen
If Err<>32755 Then
FileToOpen=CommonDialog1.FileName
Else
MsgBox "Cancel Was Pressed"
End If
End Sub
This Should Work
------------------
Visual Basic Programmer (at least I want to be one)
------------------
PolComSoft
You will hear a lot about it.
lumin
Nov 16th, 1999, 07:04 AM
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
lumin
Nov 16th, 1999, 07:12 AM
hi again...
if my example is not working you can use the
example that is displayed on the topic below named COMMONDIALOG
-Lumin
struntz
Nov 16th, 1999, 07:38 AM
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
lumin
Nov 16th, 1999, 05:47 PM
yeah probably.. but now you are making thing just easy : )
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.