I think you want Application.GetSaveAsFilename. Here's an example.
Sub Test()
Dim sFile As String
Dim lFile As Long
Dim sSql As String
sFile = Application.GetSaveAsFilename(, "*.txt,*.txt", , "Save SQL File")
If sFile <> "False" Then
sSql = "Select * from abc"
lFile = FreeFile
Open sFile For Append As lFile
Print #lFile, sSql
Close lFile
End If
End Sub
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
Sub TestCopy()
Dim sNewFile As String, sOldFile As String
Dim lFile As Long
Dim sSql As String
sNewFile = Application.GetSaveAsFilename(, "*.txt,*.txt", , "Save SQL File")
If sNewFile <> "False" Then
sSql = "Select * from abc"
sOldFile = "C:\Book1.txt"
lFile = FreeFile
Open sOldFile For Append As lFile
Print #lFile, sSql
Close lFile
FileCopy sOldFile, sNewFile
End If
End Sub
You'll end up with two files - one at C:\Book1.txt and one where the user chooses.