ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Automatic File Name from Templates (https://www.excelbanter.com/excel-programming/323277-automatic-file-name-templates.html)

alanford

Automatic File Name from Templates
 
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


Greg Brow

Automatic File Name from Templates
 
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



gocush[_29_]

Automatic File Name from Templates
 
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")

"alanford" wrote:

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




All times are GMT +1. The time now is 01:29 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com