LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 
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 04:07 AM.

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"