Thread: SAVE AS MACRO
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Patrick Molloy[_2_] Patrick Molloy[_2_] is offline
external usenet poster
 
Posts: 1,298
Default SAVE AS MACRO

hi. this is another branch - you should stay with the original thread if
possible.

try this:

Dim flName As String
Dim flFormat As Long
Dim msg As String
Dim Style As String
Dim sFilename As String

msg = "Are you sure you want to save the Smith quote?"
Style = vbYesNo + vbInformation + vbDefaultButton2


If MsgBox(msg, Style) = vbYes Then

flFormat = ActiveWorkbook.FileFormat

DefaultFolder = "M:\Design\"

ChDrive "M"
ChDir DefaultFolder
DefaultFilename = Range("C1")

'what this for idf you're asking the user to select?
If Right(UCase(DefaultFilename), 3) < "XLS" Then
DefaultFilename = DefaultFilename & Format(Date, "ddmmyyyy") &
".xls"
End If

flToSave = Application.GetSaveAsFilename(flName, filefilter:="Excel
Files (*.xls),*.xls", _
Title:="Save File As...")

If flToSave = False Then

Exit Sub
End If

ThisWorkbook.SaveAs Filename:=flToSave, FileFormat:=flFormat

End If


"Neil Holden" wrote:

Below is the code that brings up the SAVE as prompt, and save to a default
location, I thought i had the correct code to automatically insert a cell
reference and the current date in the file name. Can you assist please?

Dim flToSave As Variant 'brings up save as dialogue filling in file name
with Job number
Dim flName As String
Dim flFormat As Long
Dim Response As String
Dim msg As String
Dim Style As String
Dim sFilename As String
Dim ans

msg = "Are you sure you want to save the Smith quote?"
Style = vbYesNo + vbInformation + vbDefaultButton2

Response = MsgBox(msg, Style)
If Response = vbYes Then

flFormat = ActiveWorkbook.FileFormat

DefaultFolder = "M:\Design"
If Right(DefaultFolder, 1) < "\" Then
DefaultFolder = DefaultFolder & "\"
End If

DefaultFilename = Range("C1")

If Right(UCase(DefaultFilename), 2) < "XLS" Then
DefaultFilename = DefaultFilename & Format(Date, "ddmmyyyy") & ".xls"
DefaultFilename = DefaultFilename & ".xls"
End If

flToSave = Application.GetSaveAsFilename(flName, filefilter:="Excel
Files (*.xls),*.xls", _
Title:="Save File As...")


If flToSave = False Then

Exit Sub

Else

ThisWorkbook.SaveAs Filename:=flToSave, FileFormat:=flFormat


End If