Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SaveAs and Common Dialog

Status
Not open for further replies.

3576

Programmer
Jan 28, 2005
32
US
Is there a function such as SaveAs in Common Dialog control?
I need to provide the user with the ability to select a file and rename it right away preferably using Common Dialog control.

Any help is appreciated.

Thanks,

TW
 
I should add that when I used the pCommonDialog.ShowSave, the file was not saved somehow.
TW
 
The commondialog control allows you to choose a filename, it doesn't do any opening or saving on it's own.

To do a 'Save As' you can use the Name...As.... command

A quick example using a CommonDialog called cdl1:
Code:
Dim myfile As String
   With cdl1
      .ShowOpen
   End With
   myfile = cdl1.FileName
   MsgBox "Choose new name"
   With cdl1
   .ShowSave
   End With
   Name myfile As cdl1.FileName

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
What I meant by saying "I used the pCommonDialog.ShowSave" to save a file, is that when that pCommonDialog open I entered a new name and clicked on the "Save" button in the pCommonDialog control but the file wasn't saved. Shouldn't the file be saved?

Thanks,

TW
 
Did you use the 'Name...As' as suggested by johnwm??
As far as I can see that will overwrite/rename the original file with the new filename?

johnwm can you confirm/deny this?

If this is so and you want to keep the original you could replace the 'Name...As' in john's code with
Code:
FileCopy myfile, cdl1.FileName

Hope this helps

Harleyquinn

---------------------------------
For tsunami relief donations
 
3576,
As I said above, <q>The commondialog control allows you to choose a filename, it doesn't do any opening or saving on it's own.</q> It's up to you to save, as shown in the snippet above!

Harleyquinn,
Yes it surely will - that's what I believe OP requested <q>rename</q>

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
Thank you both for your help. I actually can use both methods in my code.

TW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top