ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   SaveAs... (https://www.excelbanter.com/excel-programming/286303-saveas.html)

Chris Gorham[_3_]

SaveAs...
 
Hi,

I'm trying to write some code that will allow me to do
this:

if thisworkbookalreadysaved then
activework.save
else
filesavename = Application.GetSaveAsFilename
(fileFilter:="Microsoft Excel Workbook (*.xls), *.xls")

If filesavename < False Then ActiveWorkbook.SaveAs
Filename:=filesavename, FileFormat:=xlNormal
end if

the key issue is whether the workbook has been saved in
the past and there is a directory path to it - if, so then
just save it, if not then bring up the saveas dialog box

thks...Chris




Dave Peterson[_3_]

SaveAs...
 
If thisworkbook.path = "" then
'never saved before


(Don't you hate it when the answer is in your own question!!! <bg)

Chris Gorham wrote:

Hi,

I'm trying to write some code that will allow me to do
this:

if thisworkbookalreadysaved then
activework.save
else
filesavename = Application.GetSaveAsFilename
(fileFilter:="Microsoft Excel Workbook (*.xls), *.xls")

If filesavename < False Then ActiveWorkbook.SaveAs
Filename:=filesavename, FileFormat:=xlNormal
end if

the key issue is whether the workbook has been saved in
the past and there is a directory path to it - if, so then
just save it, if not then bring up the saveas dialog box

thks...Chris


--

Dave Peterson


Chip Pearson

SaveAs...
 
Chris,

Test the ThisWorkbook.Path property. If it is empty, then the
workbook has never been saved. For example,

If ThisWorkbook.Path < "" Then
ThisWorkbook.Save
Else
'.. GetSaveAsFilename
' SaveAs
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Chris Gorham" wrote in
message ...
Hi,

I'm trying to write some code that will allow me to do
this:

if thisworkbookalreadysaved then
activework.save
else
filesavename = Application.GetSaveAsFilename
(fileFilter:="Microsoft Excel Workbook (*.xls), *.xls")

If filesavename < False Then ActiveWorkbook.SaveAs
Filename:=filesavename, FileFormat:=xlNormal
end if

the key issue is whether the workbook has been saved in
the past and there is a directory path to it - if, so then
just save it, if not then bring up the saveas dialog box

thks...Chris







All times are GMT +1. The time now is 10:56 AM.

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