Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default 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.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default 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.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default 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.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default 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.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default 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.




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to save XLSX files without using 'Save As' and different na SlackerBoy Setting up and Configuration of Excel 1 March 14th 09 09:14 PM
Where does Save As Automatic Backup save its files? JoAnn Excel Discussion (Misc queries) 3 April 4th 08 08:48 PM
Can I save excel files as web connected files Sophia Chen Excel Discussion (Misc queries) 0 September 27th 06 11:34 PM
Macro to open *.dat files and save as .txt (comma delimited text files) [email protected] Excel Programming 2 November 30th 05 05:50 AM
copy subfolders, replace text in files and save files in copied subfolders pieros Excel Programming 0 November 1st 05 12:08 PM


All times are GMT +1. The time now is 05:44 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"