ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Files SAVE AS (https://www.excelbanter.com/excel-programming/406981-files-save.html)

Rpettis31

Files SAVE AS
 
I am trying to write a macro that will allow me to save a file as a "myfile,
plus the current date in xls. The macro has already converted the "myfile"
from a text format.



joel

Files SAVE AS
 
myfile = ThisWorkbook.Name
'test if there is a file extension
StrDate = Format(Date, "mm-dd-yy")
If InStr(myfile, ".") 0 Then
Pre = Left(myfile, InStr(myfile, ".") - 1)
Post = Mid(myfile, InStr(myfile, "."))
NewName = Pre & "_" & StrDate & Post
Else
NewName = myfile & "_" & StrDate & ".xls"
End If

ThisWorkbook.SaveAs Filename:=NewName

"Rpettis31" wrote:

I am trying to write a macro that will allow me to save a file as a "myfile,
plus the current date in xls. The macro has already converted the "myfile"
from a text format.



JLGWhiz

Files SAVE AS
 
I assume you mean that myFile is a variable containing the file name. If so,

ActiveWorkbook.SaveAs FileName:= myFile & "-" & _
Format(Now, "m/d/yy") & ".xls"

This puts a - between the file name and date.

"Rpettis31" wrote:

I am trying to write a macro that will allow me to save a file as a "myfile,
plus the current date in xls. The macro has already converted the "myfile"
from a text format.



Gord Dibben

Files SAVE AS
 
The / is an illegal character.

Suggest "mmddyy" or "mdyy"


Gord Dibben MS Excel MVP

On Sun, 2 Mar 2008 12:11:01 -0800, JLGWhiz
wrote:

I assume you mean that myFile is a variable containing the file name. If so,

ActiveWorkbook.SaveAs FileName:= myFile & "-" & _
Format(Now, "m/d/yy") & ".xls"

This puts a - between the file name and date.

"Rpettis31" wrote:

I am trying to write a macro that will allow me to save a file as a "myfile,
plus the current date in xls. The macro has already converted the "myfile"
from a text format.




FSt1

Files SAVE AS
 
hi
i thought slashes, forward or back, were forbidden characters in a file name.

Regards
FSt1

"JLGWhiz" wrote:

I assume you mean that myFile is a variable containing the file name. If so,

ActiveWorkbook.SaveAs FileName:= myFile & "-" & _
Format(Now, "m/d/yy") & ".xls"

This puts a - between the file name and date.

"Rpettis31" wrote:

I am trying to write a macro that will allow me to save a file as a "myfile,
plus the current date in xls. The macro has already converted the "myfile"
from a text format.



JLGWhiz

Files SAVE AS
 
I have an excuse. My memory is failing. <g

"Gord Dibben" wrote:

The / is an illegal character.

Suggest "mmddyy" or "mdyy"


Gord Dibben MS Excel MVP

On Sun, 2 Mar 2008 12:11:01 -0800, JLGWhiz
wrote:

I assume you mean that myFile is a variable containing the file name. If so,

ActiveWorkbook.SaveAs FileName:= myFile & "-" & _
Format(Now, "m/d/yy") & ".xls"

This puts a - between the file name and date.

"Rpettis31" wrote:

I am trying to write a macro that will allow me to save a file as a "myfile,
plus the current date in xls. The macro has already converted the "myfile"
from a text format.





Gord Dibben

Files SAVE AS
 
I amazed myself by even noticing<g


Gord

On Sun, 2 Mar 2008 12:29:02 -0800, JLGWhiz
wrote:

I have an excuse. My memory is failing. <g




All times are GMT +1. The time now is 08:00 AM.

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