View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Neil Holden Neil Holden is offline
external usenet poster
 
Posts: 163
Default PLEASE HELP!! SAVE MACRO

Well a genius!!! THANKYOU!!!!!!

"Incidental" wrote:

Hi Neil

The code below is one way of doing it, if you pass the default folder
along with the filename in the GetSaveAsFileName it will load your
default directory, and if there is an error it will load the default
directory for office. I created the folder C:\Test just for testing
the code you can replace this with your own Directory.

Sub SaveAsWithDefaults()

Dim Response As String
Dim DefaultFolder As String, DefaultFileName As String
Dim FileToSave

Response = MsgBox("Are you sure you want to save the Smith
quote?", _
vbYesNo + vbInformation + vbDefaultButton2)

If Response = vbYes Then
DefaultFolder = "C:\Test"
If Right(DefaultFolder, 1) < "\" Then
DefaultFolder = DefaultFolder & "\"
End If
DefaultFileName = Range("C1")
If Right(UCase(DefaultFileName), 3) < "XLS" Then
DefaultFileName = DefaultFileName & " " & _
Format(Date, "dd-mm-yyyy") & ".xls"
End If
FileToSave = Application.GetSaveAsFilename _
(DefaultFolder & DefaultFileName, filefilter:="Excel Files
(*.xls)," _
& "*.xls", Title:="Save File As...")
If FileToSave = False Then
Exit Sub
Else
ThisWorkbook.SaveAs _
Filename:=FileToSave, _
FileFormat:=ActiveWorkbook.FileFormat
End If
End If

End Sub

I hope this helps you out

Steve