Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to Save As with custom file name

I have various templates varing in the number of worksheets. There i
one worksheet called "IMPORT2004" that's common in all the files.

I need a macro that saves just this specific worksheet as a CSV fil
into a share drive called "M:/2004/Import". And that CSV file needs t
have a custom name. The name of the template is always in cell A2 &
reference number is always in cell A5 of the "IMPORT2004" tab. Eac
month, the reference number changes with the data.

So if the template was called "Template One" & the ref# was "12345"
the CSV file should be named "Template One 12345". The name of the fil
found in A2 is also what the file is saved as.

If this "custom naming" can't be done this way, is there a way t
generate some sort of unique identifier that distinguishes one templat
from an other & also one version from an other?

Thanks in advanc

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro to Save As with custom file name

Sub SaveSheet()
worksheets("Import2004").Copy
ActiveWorkbook.SaveAs Filename = "M:\2004\Import\" & _
Activesheet.Range("A2").Value & Range("A5").Value & _
".cvs", FileFormat:=xlCSV
ActiveWorkbook.Close SaveChanges:=False
End Sub

--
Regards,
Tom Ogilvy

"hailnorm " wrote in message
...
I have various templates varing in the number of worksheets. There is
one worksheet called "IMPORT2004" that's common in all the files.

I need a macro that saves just this specific worksheet as a CSV file
into a share drive called "M:/2004/Import". And that CSV file needs to
have a custom name. The name of the template is always in cell A2 & a
reference number is always in cell A5 of the "IMPORT2004" tab. Each
month, the reference number changes with the data.

So if the template was called "Template One" & the ref# was "12345",
the CSV file should be named "Template One 12345". The name of the file
found in A2 is also what the file is saved as.

If this "custom naming" can't be done this way, is there a way to
generate some sort of unique identifier that distinguishes one template
from an other & also one version from an other?

Thanks in advance


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to Save As with custom file name

Thanks Tom. But the following script always produces a file name
"FALSE.csv". Also, shouldn't---

Activesheet.Range("A2").Value & Range("A5").Value & _
[b]".cvs"[/B}, FileFormat:=xlCSV

be ... Value & _[b]".csv"[/B}, FileFormat:=xlCSV

The file still saves as "FALSE.csv" if I make the change. Is ther
something that's missing???


Tom Ogilvy wrote:
[b]Sub SaveSheet()
worksheets("Import2004").Copy
ActiveWorkbook.SaveAs Filename = "M:\2004\Import\" & _
Activesheet.Range("A2").Value & Range("A5").Value & _
".cvs", FileFormat:=xlCSV
ActiveWorkbook.Close SaveChanges:=False
End Su


--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default Macro to Save As with custom file name

what are all those [b] 's ??
Tom didn't have them

Tom Ogilvy wrote:
Sub SaveSheet()
worksheets("Import2004").Copy
ActiveWorkbook.SaveAs Filename = "M:\2004\Import\" &
Activesheet.Range("A2").Value & Range("A5").Value & ".cvs",
FileFormat:=xlCSV
ActiveWorkbook.Close SaveChanges:=False
End Sub
--
Patrick Molloy
Microsoft Excel MVP
---------------------------------
"hailnorm " wrote in message
...
Thanks Tom. But the following script always produces a file named
"FALSE.csv". Also, shouldn't---

Activesheet.Range("A2").Value & Range("A5").Value & _
[b]".cvs"[/B}, FileFormat:=xlCSV

be ... Value & _[b]".csv"[/B}, FileFormat:=xlCSV

The file still saves as "FALSE.csv" if I make the change. Is there
something that's missing???


Tom Ogilvy wrote:
[b]Sub SaveSheet()
worksheets("Import2004").Copy
ActiveWorkbook.SaveAs Filename = "M:\2004\Import\" & _
Activesheet.Range("A2").Value & Range("A5").Value & _
".cvs", FileFormat:=xlCSV
ActiveWorkbook.Close SaveChanges:=False
End Sub



---
Message posted from http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to Save As with custom file name

I was just trying to bold it in the post. It's not included in th
macro.

The script creates a csv file called "FALSE" in the M:\2004 instead o
the M:\2004\Import\. Is there something that I'm missing??? Th
"Import2004" worksheet is formatted as text or number.


Patrick Molloy wrote:
*what are all those [b] 's ??
Tom didn't have them

Tom Ogilvy wrote:
Sub SaveSheet()
worksheets("Import2004").Copy
ActiveWorkbook.SaveAs Filename = "M:\2004\Import\" &
Activesheet.Range("A2").Value & Range("A5").Value & ".cvs",
FileFormat:=xlCSV
ActiveWorkbook.Close SaveChanges:=False
End Sub
--
Patrick Molloy
Microsoft Excel MVP
---------------------------------
"hailnorm " wrote i
message
...
Thanks Tom. But the following script always produces a file named
"FALSE.csv". Also, shouldn't---

Activesheet.Range("A2").Value & Range("A5").Value & _
[b]".cvs"[/B}, FileFormat:=xlCSV

be ... Value & _[b]".csv"[/B}, FileFormat:=xlCSV

The file still saves as "FALSE.csv" if I make the change. Is there
something that's missing???


Tom Ogilvy wrote:
[b]Sub SaveSheet()
worksheets("Import2004").Copy
ActiveWorkbook.SaveAs Filename = "M:\2004\Import\" & _
Activesheet.Range("A2").Value & Range("A5").Value & _
".cvs", FileFormat:=xlCSV
ActiveWorkbook.Close SaveChanges:=False
End Sub



---
Message posted from http://www.ExcelForum.com/


--
Message posted from http://www.ExcelForum.com

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
2007 Macro to Open File, Delete Contents, Save New File Flintstone[_2_] Excel Discussion (Misc queries) 2 February 1st 10 11:25 PM
On custom toolbar, how to save macro link to flashdrive ? John Nelson Excel Discussion (Misc queries) 1 February 10th 09 10:49 PM
Save Macro and Custom Toolbar in Worksheet Pat Excel Discussion (Misc queries) 1 April 24th 08 04:12 AM
Custom Menu with Macro doesn't save. Brijesh Excel Discussion (Misc queries) 2 December 12th 07 11:35 PM
Automate open file, update links, run macro, close and save file Geoff[_7_] Excel Programming 2 August 26th 03 10:13 PM


All times are GMT +1. The time now is 09:28 AM.

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

About Us

"It's about Microsoft Excel"