Automatic File Name from Templates

  • Thread starter Thread starter alanford
  • Start date Start date
A

alanford

Hello there,
Does any one know if it is possible to pickup a text value from a
precise cell and assign it as a file name?
I have prepared a Template and on save as I would like to pickup the
text inserted into call C3 and save this new file into a directory
C:\mydir.
Thank you
Alan
 
Sub UserFileSave()

Dim Fname, Suggestion, Hdr

Suggestion = Range("c3").Value

Hdr = "Please choose a Location and Name then click Save."

On Error GoTo ERRH

Fname = Application.GetSaveAsFilename(Suggestion,
fileFilter:="ExcelFile(*.xls), *.xls)", Title:=Hdr)

If Fname = False Then

'Handle Cancel

'UserCancel

Else

ThisWorkbook.SaveAs Filename:=Fname

End If

Exit Sub

ERRH:

On Error GoTo 0

MsgBox "Try another Name"

UserFileSave

End Sub
 
Or if you want to automate it without giving the user the option:


ThisWorkbook.SaveAs Filename:=Range("C3").Value
or perhaps something like:
ThisWorkbook.SaveAs Filename:=Range("C3").Value & Format(Date, " mm-dd-yy")
 

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

Back
Top