Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Saving File with macro

I can't find the right code in any posts for this type of save. I just want
to save the current file to a specified location without specifying the
filename in the macro.
In the macro, the active file is a template that needs to be saved as a
spreadsheet. Ideally, I want to replace an existing file ("FILM 08-30-06")
using the current date in the format shown ("FILM 09-05-06").

tia -kelli
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Saving File with macro

I should mention that I want to choose a file to be replaced from the files
in the save-to location, and have the current file name itself using the text
portion of that filename, and replacing the date portion with the current
date.



"KelliInCali" wrote:

I can't find the right code in any posts for this type of save. I just want
to save the current file to a specified location without specifying the
filename in the macro.
In the macro, the active file is a template that needs to be saved as a
spreadsheet. Ideally, I want to replace an existing file ("FILM 08-30-06")
using the current date in the format shown ("FILM 09-05-06").

tia -kelli

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default Saving File with macro

Something like:
ActiveWorkbook.SaveAs Filename:="C:\YourPath\FILM " &
Format(Date(),"mm-dd-yy")
or more dynamic like:
ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Path & _
Application.PathSeparator & Left(ActiveWorkbook.Name, _
InStr(1,ActiveWorkbook.Name," ") - 1) & Format(Date(),"mm-dd-yy")

Charles

KelliInCali wrote:
I can't find the right code in any posts for this type of save. I just want
to save the current file to a specified location without specifying the
filename in the macro.
In the macro, the active file is a template that needs to be saved as a
spreadsheet. Ideally, I want to replace an existing file ("FILM 08-30-06")
using the current date in the format shown ("FILM 09-05-06").

tia -kelli


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Saving File with macro

This will do the save with the date included in the filename:

Sub gsnu()
Dim s1 As String, s2 As String, s3 As String, s4 As String
s1 = "C:\Documents and Settings\Owner\Desktop\"
s2 = "FILM " & Format(Date, "mm-dd-yy")
s3 = ".xls"
s4 = s1 & s2 & s3
ChDir s1
ActiveWorkbook.SaveAs Filename:=s4
End Sub

You, of course, will replace s1 with your directory. The macro also does
not delete previously saved versions.
--
Gary's Student


"KelliInCali" wrote:

I should mention that I want to choose a file to be replaced from the files
in the save-to location, and have the current file name itself using the text
portion of that filename, and replacing the date portion with the current
date.



"KelliInCali" wrote:

I can't find the right code in any posts for this type of save. I just want
to save the current file to a specified location without specifying the
filename in the macro.
In the macro, the active file is a template that needs to be saved as a
spreadsheet. Ideally, I want to replace an existing file ("FILM 08-30-06")
using the current date in the format shown ("FILM 09-05-06").

tia -kelli

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Saving File with macro

Thanks Charles and GS, but these don't seem to do it. "FILM" won't always be
"FILM". I run this same macro for various data sets so I need to be able to
manually choose the existing file to be replaced each time and have the text
portion of the name be derived from that file:
(FILM 08-30-06, ART 08-30-06, ELEC 08-30-06, etc.)



"Die_Another_Day" wrote:

Something like:
ActiveWorkbook.SaveAs Filename:="C:\YourPath\FILM " &
Format(Date(),"mm-dd-yy")
or more dynamic like:
ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Path & _
Application.PathSeparator & Left(ActiveWorkbook.Name, _
InStr(1,ActiveWorkbook.Name," ") - 1) & Format(Date(),"mm-dd-yy")

Charles

KelliInCali wrote:
I can't find the right code in any posts for this type of save. I just want
to save the current file to a specified location without specifying the
filename in the macro.
In the macro, the active file is a template that needs to be saved as a
spreadsheet. Ideally, I want to replace an existing file ("FILM 08-30-06")
using the current date in the format shown ("FILM 09-05-06").

tia -kelli





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Saving File with macro

Well, O.K then:


Sub gsnu()
Dim s1 As String, s2 As String, s3 As String, s4 As String
s1 = "C:\Documents and Settings\Owner\Desktop\"
s2 = Application.InputBox(prompt:="File Name?", Type:=2)
s2 = s2 & " " & Format(Date, "mm-dd-yy")
s3 = ".xls"
s4 = s1 & s2 & s3
ChDir s1
ActiveWorkbook.SaveAs Filename:=s4
End Sub
--
Gary's Student


"KelliInCali" wrote:

Thanks Charles and GS, but these don't seem to do it. "FILM" won't always be
"FILM". I run this same macro for various data sets so I need to be able to
manually choose the existing file to be replaced each time and have the text
portion of the name be derived from that file:
(FILM 08-30-06, ART 08-30-06, ELEC 08-30-06, etc.)



"Die_Another_Day" wrote:

Something like:
ActiveWorkbook.SaveAs Filename:="C:\YourPath\FILM " &
Format(Date(),"mm-dd-yy")
or more dynamic like:
ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Path & _
Application.PathSeparator & Left(ActiveWorkbook.Name, _
InStr(1,ActiveWorkbook.Name," ") - 1) & Format(Date(),"mm-dd-yy")

Charles

KelliInCali wrote:
I can't find the right code in any posts for this type of save. I just want
to save the current file to a specified location without specifying the
filename in the macro.
In the macro, the active file is a template that needs to be saved as a
spreadsheet. Ideally, I want to replace an existing file ("FILM 08-30-06")
using the current date in the format shown ("FILM 09-05-06").

tia -kelli



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Saving File with macro

Nope... still doesn't work for me. Everything works until the end, but then
it has a problem with an earlier line of code. How about this... How do I
just prompt the "Save As" window to come up? The user will choose the place
and name manually, but I want the "save" process to begin at the end of my
macro.

thanks,
kelli




"Gary''s Student" wrote:

Well, O.K then:


Sub gsnu()
Dim s1 As String, s2 As String, s3 As String, s4 As String
s1 = "C:\Documents and Settings\Owner\Desktop\"
s2 = Application.InputBox(prompt:="File Name?", Type:=2)
s2 = s2 & " " & Format(Date, "mm-dd-yy")
s3 = ".xls"
s4 = s1 & s2 & s3
ChDir s1
ActiveWorkbook.SaveAs Filename:=s4
End Sub
--
Gary's Student


"KelliInCali" wrote:

Thanks Charles and GS, but these don't seem to do it. "FILM" won't always be
"FILM". I run this same macro for various data sets so I need to be able to
manually choose the existing file to be replaced each time and have the text
portion of the name be derived from that file:
(FILM 08-30-06, ART 08-30-06, ELEC 08-30-06, etc.)



"Die_Another_Day" wrote:

Something like:
ActiveWorkbook.SaveAs Filename:="C:\YourPath\FILM " &
Format(Date(),"mm-dd-yy")
or more dynamic like:
ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Path & _
Application.PathSeparator & Left(ActiveWorkbook.Name, _
InStr(1,ActiveWorkbook.Name," ") - 1) & Format(Date(),"mm-dd-yy")

Charles

KelliInCali wrote:
I can't find the right code in any posts for this type of save. I just want
to save the current file to a specified location without specifying the
filename in the macro.
In the macro, the active file is a template that needs to be saved as a
spreadsheet. Ideally, I want to replace an existing file ("FILM 08-30-06")
using the current date in the format shown ("FILM 09-05-06").

tia -kelli


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Saving File with macro

Maybe...

Option Explicit
Sub testme()

Dim myNewFileName As String
Dim myPath As String
Dim wkbk As Workbook

Set wkbk = ActiveWorkbook

myPath = wkbk.Path & "\"
'or set it to the path you want

myNewFileName = wkbk.Name

'strip off .xls
If LCase(Right(myNewFileName, 4)) = ".xls" Then
myNewFileName = Left(myNewFileName, Len(myNewFileName) - 4)
End If

'strip off date
If Right(myNewFileName, 9) Like " ##-##-##" Then
myNewFileName = Left(myNewFileName, Len(myNewFileName) - 9)
End If

'add back space and date
myNewFileName = myNewFileName & " " & Format(Date, "mm-dd-yy") & ".xls"

'MsgBox myNewFileName 'just to verify

Application.DisplayAlerts = False 'overwrite without prompt
wkbk.SaveAs Filename:=myPath & myNewFileName, FileFormat:=xlWorkbookNormal
Application.DisplayAlerts = True

End Sub


KelliInCali wrote:

I can't find the right code in any posts for this type of save. I just want
to save the current file to a specified location without specifying the
filename in the macro.
In the macro, the active file is a template that needs to be saved as a
spreadsheet. Ideally, I want to replace an existing file ("FILM 08-30-06")
using the current date in the format shown ("FILM 09-05-06").

tia -kelli


--

Dave Peterson
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
File Saving macro ?!?! hemants[_5_] Excel Programming 1 August 23rd 06 12:20 AM
Macro Help for Saving a file [email protected] Excel Worksheet Functions 3 May 12th 06 05:16 PM
Saving a file via a Macro? Jim Rech Excel Programming 0 June 23rd 04 07:39 PM
Saving a file in a macro Eric Dreshfield Excel Programming 2 September 10th 03 04:49 PM
Saving a new file with a macro Mike[_36_] Excel Programming 0 July 23rd 03 03:55 PM


All times are GMT +1. The time now is 08:32 PM.

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

About Us

"It's about Microsoft Excel"