Results 1 to 2 of 2

Thread: CommonDialog Save as, and renaming files

  1. #1

    Thread Starter
    Member
    Join Date
    May 2000
    Posts
    37

    CommonDialog Save as, and renaming files

    Please help me with my code.

    I'm not sure why it's not working.

    What I'm doing is showing the GetSaveAs dialog box. I'm trying to rename newfile to a different filename, which is a filename entered by the user in the Save as dialog box.

    However, if the user selects a file which already exists, this code doesn't work. It doesn't rename it. How should I go about this? Any ideas?

    Code:
    Private Sub SaveFile()
    
    On Error GoTo UserCanceled
    CommonDialog1.Flags = cdlOFNOverwritePrompt
    CommonDialog1.Filter = "Excel Spreadsheets| *.xls"
    CommonDialog1.CancelError = True '<when they press cancel it makes an error
    CommonDialog1.InitDir = lstDirListBox.Path
    CommonDialog1.ShowSave
    Name newfile As CommonDialog1.FileName
    Exit Sub
    
    UserCanceled:
    
    End Sub
    Thanks for reading my post!

  2. #2
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    is the file you try to rename in use ?
    if so, an error will occur when you try to rename it. you are using error handler that only exits the sub assuming the only error that can occur is the cancel error....
    -= a peet post =-

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