ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   macro to save a file (https://www.excelbanter.com/excel-programming/371909-macro-save-file.html)

Janis

macro to save a file
 
I recorded this macro. It works but I want the filename to be a variable not
hard coded in the macro so it saves the current file name. Is there anyway
to keep it from writing over the last one if the names are the same? Say it
saved two of the same name in the same day. Perhaps by adding the datestamp
to the variable for the name?

thanks,


Option Explicit
Sub saveforIndesign()
'
' saveIndesign Macro
ChDir "Mac OS X:Users:jrough:Documents:"

ActiveWorkbook.SaveAs Filename:= _
"Mac OS X:Users:jrough:Documents:ssp_latest_082406.xls",
FileFormat:=xlNormal _
, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
End Sub


Die_Another_Day

macro to save a file
 
Try this:
Const fPath as string = "WeirdMacintoshPathInfo"
Dim fName as string
fName = fPath & Variable & Time()

ActiveWorkbook.SaveAs FileName:=fName

HTH

Charles

Janis wrote:
I recorded this macro. It works but I want the filename to be a variable not
hard coded in the macro so it saves the current file name. Is there anyway
to keep it from writing over the last one if the names are the same? Say it
saved two of the same name in the same day. Perhaps by adding the datestamp
to the variable for the name?

thanks,


Option Explicit
Sub saveforIndesign()
'
' saveIndesign Macro
ChDir "Mac OS X:Users:jrough:Documents:"

ActiveWorkbook.SaveAs Filename:= _
"Mac OS X:Users:jrough:Documents:ssp_latest_082406.xls",
FileFormat:=xlNormal _
, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
End Sub



Mike[_96_]

macro to save a file
 
If the windows scripting host object model is available on the Mac, you can
use the filesystemobject's .fileexists property to check if the filename is
already taken.


"Janis" wrote in message
...
I recorded this macro. It works but I want the filename to be a variable

not
hard coded in the macro so it saves the current file name. Is there

anyway
to keep it from writing over the last one if the names are the same? Say

it
saved two of the same name in the same day. Perhaps by adding the

datestamp
to the variable for the name?

thanks,


Option Explicit
Sub saveforIndesign()
'
' saveIndesign Macro
ChDir "Mac OS X:Users:jrough:Documents:"

ActiveWorkbook.SaveAs Filename:= _
"Mac OS X:Users:jrough:Documents:ssp_latest_082406.xls",
FileFormat:=xlNormal _
, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False,

_
CreateBackup:=False
End Sub





All times are GMT +1. The time now is 01:33 AM.

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