After GetSaveAsFileName question

  • Thread starter Thread starter Stuart
  • Start date Start date
S

Stuart

I use GetSaveAsFileName as follows:

fName = Application.GetSaveAsFilename _
(sStr, "Excel Files (*.xls),*.xls)")
If fName <> ThisWorkbook.Name And fName <> "False" Then

I now wish to add a new single sheet workbook and name it with
the workbook name the user chose with fName.

How do I do this, please?

Regards.
 
Hi Stuart

Try something like this

Sub Test()
Dim fname As Variant
Dim NewWb As Workbook
Set NewWb = Workbooks.Add(xlWBATWorksheet)
fname = Application.GetSaveAsFilename("", _
fileFilter:="Excel Files (*.xls), *.xls")
If fname <> "False" Then
NewWb.SaveAs fname
NewWb.Close False
Set NewWb = Nothing
Else
NewWb.Close False
Set NewWb = Nothing
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top