Results 1 to 9 of 9

Thread: Problem with the Save DialogBox??? - Please help

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 1999
    Location
    Leeds, UK
    Posts
    287

    Post

    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???

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

    Post

    rino...This may or may not be it,, but have you tried turning off the CancelError property of the CommonDialog?

    Just a thought.

    - Chris

  3. #3
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523

    Post

    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).]

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 1999
    Location
    Leeds, UK
    Posts
    287

    Post

    could you give me an exact statment please???

  5. #5
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523

    Post

    do something like this:
    Code:
    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.


  6. #6
    Addicted Member
    Join Date
    Jul 1999
    Location
    Bergen, Norway
    Posts
    143

    Post

    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

  7. #7
    Addicted Member
    Join Date
    Jul 1999
    Location
    Bergen, Norway
    Posts
    143

    Post

    hi again...

    if my example is not working you can use the
    example that is displayed on the topic below named COMMONDIALOG


    -Lumin

  8. #8
    Registered User struntz's Avatar
    Join Date
    Aug 1999
    Location
    Brockway,Pa,USA
    Posts
    199

    Post

    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

  9. #9
    Addicted Member
    Join Date
    Jul 1999
    Location
    Bergen, Norway
    Posts
    143

    Post

    yeah probably.. but now you are making thing just easy : )

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