ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Saving a workbook (https://www.excelbanter.com/excel-programming/354420-saving-workbook.html)

Andrew B[_4_]

Saving a workbook
 
Hi
I am trying to save a newly created workbook, using the value of a cell
as its name.
These cell values are used in the first workbook.

[M24] = C:\Documents and Settings\Memos\ 'Pathway for file
[M19] = Memo1 'file name

Workbooks.Add

Then, I've tried the following without success:

Workbook.SaveAs ([M19] & ".xls")
or
ActiveWorkbook.SaveAs [M19] & ".xls"
or
ActiveWorkbook.SaveAs [M24] & [M19] & ".xls"
or
Workbooks(ActiveWorkbook).SaveAs [M19] & ".xls"

Can someone please help me ?

Thank you

davesexcel[_7_]

Saving a workbook
 

myfilename = "d:\somewhere\" & Range("customer") & "\"
Range("address")
ActiveWorkbook.SaveAs Filename:= _
myfilename, FileFormat _
:=xlNormal, Password:="", _
WriteResPassword:="", ReadOnlyRecommended:= _
False, CreateBackup:=False

"customer" is a named range for a subdirectory
for this to work, the subfolder already has to exist

"address" is a named range for the actual file name

you don't have to used named ranges, but I like to, because its easie
to write formulas and work with code

--
davesexce
-----------------------------------------------------------------------
davesexcel's Profile: http://www.excelforum.com/member.php...fo&userid=3170
View this thread: http://www.excelforum.com/showthread.php?threadid=51664


Nigel

Saving a workbook
 
ActiveWorkbook.SaveAs Filename:=Range("M24") & Range("M19") & ".xls"

--
Cheers
Nigel



"Andrew B" wrote in message
...
Hi
I am trying to save a newly created workbook, using the value of a cell
as its name.
These cell values are used in the first workbook.

[M24] = C:\Documents and Settings\Memos\ 'Pathway for file
[M19] = Memo1 'file name

Workbooks.Add

Then, I've tried the following without success:

Workbook.SaveAs ([M19] & ".xls")
or
ActiveWorkbook.SaveAs [M19] & ".xls"
or
ActiveWorkbook.SaveAs [M24] & [M19] & ".xls"
or
Workbooks(ActiveWorkbook).SaveAs [M19] & ".xls"

Can someone please help me ?

Thank you




Andrew B[_4_]

Saving a workbook
 
Thank you - it now works.

Andrew B


All times are GMT +1. The time now is 02:29 AM.

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