A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

File name equal cell contents



 
 
Thread Tools Display Modes
  #11  
Old March 22nd, 2006, 06:22 PM posted to microsoft.public.excel.misc
external usenet poster
 
Posts: n/a
Default File name equal cell contents

ActiveWorkbook.SaveAs Filename:="C:\" & Range("I5").Value _
& range("J5").value & ".xls", _

Change the cell to what you want.

Petester wrote:

Thanks for the information. What would be the full code for this so I can
copy and paste or how could I fix the following code that works with a ctrl-s.

Sub Macro1()
ActiveWorkbook.SaveAs Filename:="C:\" & Range("I5").Value & ".xls", _
FileFormat:=xlNormal, _
Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
End Sub

"Dave Peterson" wrote:

fname = .worksheets("sheet1").range("A1").value & _
.worksheets("sheet2").range("z99").value & _
".xls"

You could use the same sheet and adjacent cells, too.

Petester wrote:

Is there a way to have two cells in the range, so the the two cells make up
the file name?

"Frank Kabel" wrote:

Hi
in a macro
sub save_it()
dim fname
with activeworkbook
fname = .worksheets("sheet1").range("A1").value & ".xls"
.saveas fname
end with
end sub


"-tinka" wrote:

Is it possible to make an Excel (2003) template (or a macro in the template)
to save a file with a specific cell-contents as file name? For example an
invoice-template where a cell contains the invoice number. I want it to
automatically save the file as "invoice-number".xls in default file location.

Thanks... :-)


--

Dave Peterson


--

Dave Peterson
  #12  
Old March 23rd, 2006, 12:25 AM posted to microsoft.public.excel.misc
external usenet poster
 
Posts: n/a
Default File name equal cell contents

Thank you very much. This worked, it's great!

"Dave Peterson" wrote:

ActiveWorkbook.SaveAs Filename:="C:\" & Range("I5").Value _
& range("J5").value & ".xls", _

Change the cell to what you want.

Petester wrote:

Thanks for the information. What would be the full code for this so I can
copy and paste or how could I fix the following code that works with a ctrl-s.

Sub Macro1()
ActiveWorkbook.SaveAs Filename:="C:\" & Range("I5").Value & ".xls", _
FileFormat:=xlNormal, _
Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
End Sub

"Dave Peterson" wrote:

fname = .worksheets("sheet1").range("A1").value & _
.worksheets("sheet2").range("z99").value & _
".xls"

You could use the same sheet and adjacent cells, too.

Petester wrote:

Is there a way to have two cells in the range, so the the two cells make up
the file name?

"Frank Kabel" wrote:

Hi
in a macro
sub save_it()
dim fname
with activeworkbook
fname = .worksheets("sheet1").range("A1").value & ".xls"
.saveas fname
end with
end sub


"-tinka" wrote:

Is it possible to make an Excel (2003) template (or a macro in the template)
to save a file with a specific cell-contents as file name? For example an
invoice-template where a cell contains the invoice number. I want it to
automatically save the file as "invoice-number".xls in default file location.

Thanks... :-)

--

Dave Peterson


--

Dave Peterson

  #13  
Old March 30th, 2006, 11:10 PM posted to microsoft.public.excel.misc
external usenet poster
 
Posts: n/a
Default File name equal cell contents

This was a really useful place to start for me, but I have a slightly
different variation!

I have a linked spreadsheet (data on the backend and a really complicated
spreadsheet filled with afore mentioned data on the front end). I need to be
able to save as pdf (or print to PDF) the front page directly to a file.
Hopefully being able to use the handy information here about pulling the
client information from a cell.

Can anyone help with a macro that would allow me to extract just the first
page and save to file; generating a file name from a cell. Saving in PDF if
at all possible....but I would live with .xls

"Dave Peterson" wrote:

ActiveWorkbook.SaveAs Filename:="C:\" & Range("I5").Value _
& range("J5").value & ".xls", _

Change the cell to what you want.

Petester wrote:

Thanks for the information. What would be the full code for this so I can
copy and paste or how could I fix the following code that works with a ctrl-s.

Sub Macro1()
ActiveWorkbook.SaveAs Filename:="C:\" & Range("I5").Value & ".xls", _
FileFormat:=xlNormal, _
Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
End Sub

"Dave Peterson" wrote:

fname = .worksheets("sheet1").range("A1").value & _
.worksheets("sheet2").range("z99").value & _
".xls"

You could use the same sheet and adjacent cells, too.

Petester wrote:

Is there a way to have two cells in the range, so the the two cells make up
the file name?

"Frank Kabel" wrote:

Hi
in a macro
sub save_it()
dim fname
with activeworkbook
fname = .worksheets("sheet1").range("A1").value & ".xls"
.saveas fname
end with
end sub


"-tinka" wrote:

Is it possible to make an Excel (2003) template (or a macro in the template)
to save a file with a specific cell-contents as file name? For example an
invoice-template where a cell contains the invoice number. I want it to
automatically save the file as "invoice-number".xls in default file location.

Thanks... :-)

--

Dave Peterson


--

Dave Peterson

  #14  
Old March 30th, 2006, 11:20 PM posted to microsoft.public.excel.misc
external usenet poster
 
Posts: n/a
Default File name equal cell contents

Maybe.....

Dim myFileName as string
with activeworkbook
worksheets(1).copy 'to a new workbook
with activesheet
with .usedrange
.copy
.pastespecial paste:=xlpastevalues 'remove formulas???
end with
'pick up the name from some cells???
myfilename = .range("a1").value & .range("B1").value & ".xls"
myfilename = "C:\my folder\" & myfilename '????
.parent.saveas filename:=myfilename, fileformat:=xlworkbooknormal
.parent.close savechanges:=false
end with
end with

I don't speak the .pdf stuff.

southofI10chaos wrote:

This was a really useful place to start for me, but I have a slightly
different variation!

I have a linked spreadsheet (data on the backend and a really complicated
spreadsheet filled with afore mentioned data on the front end). I need to be
able to save as pdf (or print to PDF) the front page directly to a file.
Hopefully being able to use the handy information here about pulling the
client information from a cell.

Can anyone help with a macro that would allow me to extract just the first
page and save to file; generating a file name from a cell. Saving in PDF if
at all possible....but I would live with .xls

"Dave Peterson" wrote:

ActiveWorkbook.SaveAs Filename:="C:\" & Range("I5").Value _
& range("J5").value & ".xls", _

Change the cell to what you want.

Petester wrote:

Thanks for the information. What would be the full code for this so I can
copy and paste or how could I fix the following code that works with a ctrl-s.

Sub Macro1()
ActiveWorkbook.SaveAs Filename:="C:\" & Range("I5").Value & ".xls", _
FileFormat:=xlNormal, _
Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
End Sub

"Dave Peterson" wrote:

fname = .worksheets("sheet1").range("A1").value & _
.worksheets("sheet2").range("z99").value & _
".xls"

You could use the same sheet and adjacent cells, too.

Petester wrote:

Is there a way to have two cells in the range, so the the two cells make up
the file name?

"Frank Kabel" wrote:

Hi
in a macro
sub save_it()
dim fname
with activeworkbook
fname = .worksheets("sheet1").range("A1").value & ".xls"
.saveas fname
end with
end sub


"-tinka" wrote:

Is it possible to make an Excel (2003) template (or a macro in the template)
to save a file with a specific cell-contents as file name? For example an
invoice-template where a cell contains the invoice number. I want it to
automatically save the file as "invoice-number".xls in default file location.

Thanks... :-)

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
  #15  
Old June 17th, 2008, 06:46 PM posted to microsoft.public.excel.misc
Needtoknow
external usenet poster
 
Posts: 55
Default File name equal cell contents

Hi,
I'm getting back to this old question, some problems doesn't go away.

I have this macro and it works fine until invoice has already been saved.
First ofcourse excel wants to know if I want replace earlier file - no -
next popup is
"Runtime error 1004
Method 'SaveAs' of object '_Workbook' failed.

How can I get excel to say for ex "file couldn't be saved, check nr or
receiver OR replace older file" This problem doesn't come up if I want
replace old file.

Sub Macro1()

ActiveWorkbook.SaveAs Filename:="D:\SentInvoices\" & Range("C3").Value _
& Range("A8").Value & ".xls", _
FileFormat:=xlNormal, _
Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False

End Sub
 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cell Contents Saved in File Name? Laurie Pasion Worksheet Functions 1 August 3rd, 2004 02:20 AM
You do not have exclusive access... ERROR Robin General Discussion 1 July 6th, 2004 01:18 AM
Unsafe Attachments Ron Installation & Setup 2 June 9th, 2004 01:55 AM


All times are GMT +1. The time now is 11:04 AM.


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