Save as function

I want to do a function like this

When the user click on the "save as" button,
a "save as" dialog box ,
which appear exactly same as when you click the "File > save as" in Internet explorer(including title, save as type etc)
After user choose the type the file name and choose save, the file will be saved to the location that is chosen by the user.

How to do this?
LVL 9
william007Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics TeacherCommented:
Click on Project --> Components and check the "Microsoft Common Dialog Control" entry.  Add a CommonDialog and CommandButton control to a New Project:

Private Sub Command1_Click()
    On Error GoTo cancelled
    CommonDialog1.CancelError = True
    CommonDialog1.fileName = "c:\someFile.txt"
    CommonDialog1.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"
    CommonDialog1.ShowSave
   
    ' do something with filename...
    Dim fileName As String
    fileName = CommonDialog1.fileName
   
    Dim ff As Integer
    ff = FreeFile
    Open fileName For Output As #ff
    Print #ff, "something"
    Close #ff
cancelled:
End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
_mahrCommented:
My friend Idle_Mind here assuming here that files are "txt" files, This is his code: (Credit goes to Idle_Mind, I hope you won't Mind :D if i post some of your code here)

Private Sub Command1_Click()
    On Error GoTo cancelled
    CommonDialog1.CancelError = True
    CommonDialog1.fileName = "c:\someFile.txt"
    CommonDialog1.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"
    CommonDialog1.ShowSave
   
    ' do something with filename...
    Dim fileName As String
    NewFilePath = CommonDialog1.fileName

You can add more filters there, however i would suggest using API Version of Common Dialog, coz it suc* to add more useless components to your project. However here is what you can do (this is my code)

    FileCopy oldFilePath, NewFilePath

cancelled:
End Sub


and that's all. If file isn't so big then it won't be a big deal using FileCopy!
william007Author Commented:
Thanks:-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.