Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Anyway to save a file using a macro? Thanks Michael |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Himszy
I have used the ThisWorkbook object which refers to the workbook containing the code, but you could use ActiveWorkbook, Workbooks("NameOfBook"), Workbooks(1) ThisWorkbook.Save ThisWorkbook.SaveAs FileName:="xxxxxx.xls" -- HTH Nick Hodge Microsoft MVP - Excel Southampton, England HIS "Himszy" wrote in message ... Hi, Anyway to save a file using a macro? Thanks Michael |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Nick
How do you change the path of the file? Thanks Michael "Nick Hodge" wrote in message ... Himszy I have used the ThisWorkbook object which refers to the workbook containing the code, but you could use ActiveWorkbook, Workbooks("NameOfBook"), Workbooks(1) ThisWorkbook.Save ThisWorkbook.SaveAs FileName:="xxxxxx.xls" -- HTH Nick Hodge Microsoft MVP - Excel Southampton, England HIS "Himszy" wrote in message ... Hi, Anyway to save a file using a macro? Thanks Michael |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Michael
Saving the file will save it to either the default location (Under toolsoptionsgeneral) if it's a new book or to the location where the workbook resides for existing files. If you want to save it elsewhere you are going to need 'save as' instead of 'save'. There are tons of ways but if you want to offer a prompt for the user then use Sub saveFile() Dim sFileName As String sFileName = Application.GetSaveAsFilename() ThisWorkbook.SaveAs Filename:=sFileName End Sub The getsaveasfilename simply presents the save as box and returns the name and path of the file, you then use that to 'save as' the file. You could use the hardcode of the file path if it doesn't change, like this. ThisWorkbook.SaveAs Filename:="C:\" & sFilename Or you could use the ChDir Statement to change the 'current directory' ChDir("C:\") -- HTH Nick Hodge Microsoft MVP - Excel Southampton, England HIS "Himszy" wrote in message k... Thanks Nick How do you change the path of the file? Thanks Michael "Nick Hodge" wrote in message ... Himszy I have used the ThisWorkbook object which refers to the workbook containing the code, but you could use ActiveWorkbook, Workbooks("NameOfBook"), Workbooks(1) ThisWorkbook.Save ThisWorkbook.SaveAs FileName:="xxxxxx.xls" -- HTH Nick Hodge Microsoft MVP - Excel Southampton, England HIS "Himszy" wrote in message ... Hi, Anyway to save a file using a macro? Thanks Michael |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Saving Excel 2007 file in 2003 creates very large file | Excel Discussion (Misc queries) | |||
Saving worksheet in new file with date AND cell value as file name | Excel Discussion (Misc queries) | |||
How do I stop Excel 2000 from saving file history from file that . | Excel Discussion (Misc queries) | |||
saving an excel file as an ASCII text file without delimiters | Excel Programming | |||
Saving a file(new) using the multiple cell contents as a file name | Excel Programming |