ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   After GetSaveAsFileName question (https://www.excelbanter.com/excel-programming/303708-after-getsaveasfilename-question.html)

Stuart[_5_]

After GetSaveAsFileName question
 
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.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.716 / Virus Database: 472 - Release Date: 05/07/2004



Ron de Bruin

After GetSaveAsFileName question
 
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


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Stuart" wrote in message ...
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.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.716 / Virus Database: 472 - Release Date: 05/07/2004






All times are GMT +1. The time now is 03:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com