View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_5_] Dave Peterson[_5_] is offline
external usenet poster
 
Posts: 1,758
Default How to Save As Variable File Name

I get you.

How about something like this:

Option Explicit
Sub testme01()

Dim SaveName As Variant
Dim qrPath As String

qrPath = "C:\my documents\excel\test\"

SaveName = qrPath & ActiveCell.Value & " - " & _
ActiveCell.Offset(-3, 2).Value & " Quote"

SaveName = Application.GetSaveAsFilename _
(InitialFileName:=SaveName, filefilter:="Excel Files, *.xls")

If SaveName = False Then
MsgBox "Please try later" 'user hit cancel
Else
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=SaveName, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Application.DisplayAlerts = True
End If

End Sub

I used my own folder and changed SaveName to a variant--it can return False if
the user hits the cancel button.


wrote:

Hi,

This works, but it doesn't stop and let me update the filename. I'm
okay on the activecell since I move to it just before. The filename is
always correct, except I can't add to it.

You see the file name is "'company' - 'quote#' quote.xls", (were
company and quote# come nicely from cells), but since the customer
often does several quotes the same day for the same company they want
to be able to add something in the middle, i.e. "'company' 'stuff here'
- 'quote#' quote.xls". So I need the saveas to stop and allow filename
updates.

I hope this makes sense.

Thanks,

Michele


--

Dave Peterson