I’m creating an SQL file using Application.Path & SQL_statements.After that I write SQL statements into this file through vba.Now I want to save the file after all SQL statements are generated in an different directory.This directory depends upon the user.Hence I want to give him an Save as Dialog .
Thus, I need to save the file that I created through vba, and save it using save as dialog in a location specified by the user and delete the copy of file created by me.
I think you want Application.GetSaveAsFilename. Here’s an example.
sFile will be a string that is the full path and name. I don’t know what a “SQL file” is, so I guessed it was a file with a sql extension. sFile will be “False” if the user clicks Cancel on the dialog.
To copy the file after it’s been created
You’ll end up with two files – one at C:\Book1.txt and one where the user chooses.