Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 407
Default automating the name of my files

I have a template that will be reused to create hundreds of files and I'd
like some macro that would save the file with a smart name. If we assume
that the filename can be automated so it is in a particular cell - either
with or without the ".xls", whichever is easier for you - is there a macro
you can give me that would name the file according to the output of the
formula in that smart, variable, cell?

Thanks!
Dean


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default automating the name of my files

hi,
Not sure what you mean by "smart, variable cell" but this code works. tested.
Sub macAutoSave()
Dim rng As String
rng = Range("D4").Value ' change to your "smart cell"
ActiveWorkbook.SaveAs Filename:=rng, _
FileFormat:=xlNormal, _
Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
End Sub

But this will also save the macro with the file.
you may just want to just save your template range.
If that is the case.....
Sub macAutoSave()
Dim rng As String
Dim rng2 as range
rng = Range("D4").Value ' change to your "smart cell"
set rng2 = Range("A1:G25") 'change to your template range
Rng2.copy
Workbooks.Add
Range("A1").PasteSpecial xlPasteAll
ActiveWorkbook.SaveAs Filename:= rng, _
FileFormat:=xlNormal, _
Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
End Sub

regards
FSt1

"Dean" wrote:

I have a template that will be reused to create hundreds of files and I'd
like some macro that would save the file with a smart name. If we assume
that the filename can be automated so it is in a particular cell - either
with or without the ".xls", whichever is easier for you - is there a macro
you can give me that would name the file according to the output of the
formula in that smart, variable, cell?

Thanks!
Dean



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default automating the name of my files

hi again,
forget to mention that you could attach the macro to an custom icon.
if other people are going to be using the file, then i would drop a
command button on the sheet and attach the macro to it.

regards
FSt1

"Dean" wrote:

I have a template that will be reused to create hundreds of files and I'd
like some macro that would save the file with a smart name. If we assume
that the filename can be automated so it is in a particular cell - either
with or without the ".xls", whichever is easier for you - is there a macro
you can give me that would name the file according to the output of the
formula in that smart, variable, cell?

Thanks!
Dean



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 407
Default automating the name of my files

Actually, if I have already used that filename once, will the macro end with
the usual yes/no query, which I would like. Or would it crash?

Thanks!
Dean

"FSt1" wrote in message
...
hi,
Not sure what you mean by "smart, variable cell" but this code works.
tested.
Sub macAutoSave()
Dim rng As String
rng = Range("D4").Value ' change to your "smart cell"
ActiveWorkbook.SaveAs Filename:=rng, _
FileFormat:=xlNormal, _
Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
End Sub

But this will also save the macro with the file.
you may just want to just save your template range.
If that is the case.....
Sub macAutoSave()
Dim rng As String
Dim rng2 as range
rng = Range("D4").Value ' change to your "smart cell"
set rng2 = Range("A1:G25") 'change to your template range
Rng2.copy
Workbooks.Add
Range("A1").PasteSpecial xlPasteAll
ActiveWorkbook.SaveAs Filename:= rng, _
FileFormat:=xlNormal, _
Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
End Sub

regards
FSt1

"Dean" wrote:

I have a template that will be reused to create hundreds of files and I'd
like some macro that would save the file with a smart name. If we assume
that the filename can be automated so it is in a particular cell - either
with or without the ".xls", whichever is easier for you - is there a
macro
you can give me that would name the file according to the output of the
formula in that smart, variable, cell?

Thanks!
Dean





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automating Macros for CSV files griffin_5338 Excel Programming 1 September 21st 06 04:49 PM
Need help with automating functions BBranch Excel Worksheet Functions 1 September 4th 05 12:26 AM
Automating using VBA Automate my database Excel Worksheet Functions 1 September 1st 05 01:51 PM
Automating PP from XL Keith R[_3_] Excel Programming 0 November 20th 03 08:42 PM
automating chart generation from text files druid77 Excel Programming 2 October 4th 03 11:12 PM


All times are GMT +1. The time now is 12:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"