Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JTF JTF is offline
external usenet poster
 
Posts: 8
Default Save As - changes worksheet name

here is my code to save the current worksheet as a text file

.....
Sheets("Transaction File").Select
ActiveWorkbook.SaveAs Filename:= _
"C:\UPLOAD\NCAS" & Format(Date, "yyyymmdd") & ".txt",
FileFormat:=xlTextPrinter, CreateBackup:=False

The problem is that when the code executes, the Transaction File
worksheet is renamed with whatever name is given to the file that is
being created. I need the Transaction File worksheet to remain named
Transaction File because the next time the code is run, it looks for
that worksheet.

How can I keep the code from changing the worksheet name? Thanks!!!!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Save As - changes worksheet name

Copy your data to a new workbook, save that as the text file and then close it.

Dim wkbNew as Workbook

Set wkbNew=Workbooks.Add
' copy whole of the sheet
ThisWorkbook.Sheets("Transaction File").Cells.Copy
' paste to new book
wkbNew.Worksheets(1).Paste
Application.CutCopyMode=False
wkbNew.SaveAs Filename:= _
"C:\UPLOAD\NCAS" & Format(Date, "yyyymmdd") & ".txt",
FileFormat:=xlTextPrinter, CreateBackup:=False
wkbNew.Close SaveChanges:=False
Set wkbNew=Nothing

--
HTH

Simon


"JTF" wrote:

here is my code to save the current worksheet as a text file

.....
Sheets("Transaction File").Select
ActiveWorkbook.SaveAs Filename:= _
"C:\UPLOAD\NCAS" & Format(Date, "yyyymmdd") & ".txt",
FileFormat:=xlTextPrinter, CreateBackup:=False

The problem is that when the code executes, the Transaction File
worksheet is renamed with whatever name is given to the file that is
being created. I need the Transaction File worksheet to remain named
Transaction File because the next time the code is run, it looks for
that worksheet.

How can I keep the code from changing the worksheet name? Thanks!!!!


  #3   Report Post  
Posted to microsoft.public.excel.programming
JTF JTF is offline
external usenet poster
 
Posts: 8
Default Save As - changes worksheet name

That worked wonderfully! Many, many thanks!!!!!! I never thought of
using a new workbook.

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
How do I save only active worksheet without save all of worksheet droth Excel Worksheet Functions 2 February 21st 09 05:11 PM
When you hit Save on a template, how can you save as worksheet? cwgirl1982 Excel Worksheet Functions 1 September 4th 08 11:18 PM
WORKSHEET SAVE AS Jase Excel Discussion (Misc queries) 0 March 5th 08 08:44 PM
'Save current worksheet'; 'Open next worksheet' - two command buttons englishmustard Excel Discussion (Misc queries) 1 April 7th 06 12:54 PM
Worksheet Buttons (Save, Save As, Cut, Paste, etc.) Not Working SuzieQ12345 Excel Worksheet Functions 5 January 21st 05 02:57 PM


All times are GMT +1. The time now is 10:14 PM.

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"