PC Review


Reply
Thread Tools Rate Thread

automating the name of my files

 
 
Dean
Guest
Posts: n/a
 
      25th Jan 2007
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 With Quote
 
 
 
 
=?Utf-8?B?RlN0MQ==?=
Guest
Posts: n/a
 
      26th Jan 2007
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 With Quote
 
=?Utf-8?B?RlN0MQ==?=
Guest
Posts: n/a
 
      26th Jan 2007
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
>
>
>

 
Reply With Quote
 
Dean
Guest
Posts: n/a
 
      27th Jan 2007

"FSt1" <(E-Mail Removed)> wrote in message
news:A3D4949E-F444-4BC8-A753-(E-Mail Removed)...
> 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 With Quote
 
Dean
Guest
Posts: n/a
 
      27th Jan 2007
Your first answer looks good. I'm not sure what you mean by your second
answer - wanting to save only a range - do you mean some way to save the
file without the macro? If so, I don't need that. In any event, your
answer looks really good. Thanks!
Dean

"FSt1" <(E-Mail Removed)> wrote in message
news:A3D4949E-F444-4BC8-A753-(E-Mail Removed)...
> 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 With Quote
 
Dean
Guest
Posts: n/a
 
      28th Jan 2007
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" <(E-Mail Removed)> wrote in message
news:A3D4949E-F444-4BC8-A753-(E-Mail Removed)...
> 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automating the conversion of CSV files to XLSX files Chris Microsoft Excel Programming 3 28th Nov 2007 09:35 PM
Automating Macros for CSV files =?Utf-8?B?Z3JpZmZpbl81MzM4?= Microsoft Excel Programming 1 21st Sep 2006 04:49 PM
Automating Files Into Notes srm Microsoft Outlook Discussion 0 9th Mar 2005 01:45 PM
Re: Automating the renaming of files. Sean M Microsoft Windows 2000 File System 0 20th Aug 2004 07:41 PM
Help files for Automating Access? J S Microsoft Access 1 28th Jan 2004 11:22 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:39 PM.