PLEASE HELP!! SAVE MACRO

N

Neil Holden

Below is the code that brings up the SAVE as prompt, and want to 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 and also save in default
location. Can you assist please?

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:\Contract\Current\Nationwide\Templates\Project
Brief&SOR\Project Briefs to be Approved prior to sending inc master SOR
Project brief\"
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
 
P

Patrick Molloy

Sub xxx()

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 = "c:\temp\"


DefaultFilename = Range("C1")

If Right(UCase(DefaultFilename), 3) <> "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

flToSave = DefaultFolder & DefaultFilename

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



End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

SAVE AS MACRO 4
SAVE AS MACRO 8
MACRO to Approve or Decline 2
INPUT BOX in excel 2003 2
SAVE AS MACRO 6
EXCEL CONNECTED WITH OUTLOOK 1
SAVE AS MACRO 5
Emailing in excel 2003 5

Top