Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
That worked wonderfully! Many, many thanks!!!!!! I never thought of
using a new workbook. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I save only active worksheet without save all of worksheet | Excel Worksheet Functions | |||
When you hit Save on a template, how can you save as worksheet? | Excel Worksheet Functions | |||
WORKSHEET SAVE AS | Excel Discussion (Misc queries) | |||
'Save current worksheet'; 'Open next worksheet' - two command buttons | Excel Discussion (Misc queries) | |||
Worksheet Buttons (Save, Save As, Cut, Paste, etc.) Not Working | Excel Worksheet Functions |