Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default SaveAs without name change

I want to write code for a command button to save
the "WorkSheet1" to a .txt (tab oriended) "txtFile1".
I use the following code which works, but the side effect
is the "normal?" name change of the currend .xls file name
to "txtFile1.txt"
-----------------------------------
Private Sub cmdSaveAsTxt_Click()

ActiveWorkbook.SaveAs Filename:=txtFile1, _
FileFormat:=xlText, CreateBackup:=False

End Sub
------------------------------------
Any idea how I can do the job better?

Thanks in advance,
Pantelis
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default SaveAs without name change

When you do the save as, you are not in the xls file anymore. You are in
the text file (opened as a workbook). Thus the .txt extension. You need
to open the old .xls file and close the text file.

Private Sub cmdSaveAsTxt_Click()
sName = ThisWorkbook.Fullname
ActiveWorkbook.SaveAs Filename:=txtFile1, _
FileFormat:=xlText, CreateBackup:=False
Workbooks.Open sName
ThisWorkbook.Close SaveChanges:=False
End Sub


--
Regards,
Tom Ogilvy



"Pantelis" wrote in message
...
I want to write code for a command button to save
the "WorkSheet1" to a .txt (tab oriended) "txtFile1".
I use the following code which works, but the side effect
is the "normal?" name change of the currend .xls file name
to "txtFile1.txt"
-----------------------------------
Private Sub cmdSaveAsTxt_Click()

ActiveWorkbook.SaveAs Filename:=txtFile1, _
FileFormat:=xlText, CreateBackup:=False

End Sub
------------------------------------
Any idea how I can do the job better?

Thanks in advance,
Pantelis



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
Using SaveAs SarahN Excel Discussion (Misc queries) 3 May 14th 10 04:26 AM
SaveAs - VBA Jae[_3_] Excel Discussion (Misc queries) 4 April 10th 08 08:10 PM
SaveAs - VBA Jae Excel Discussion (Misc queries) 0 April 10th 08 06:04 AM
VBA SaveAs Value charlie Excel Discussion (Misc queries) 4 August 27th 07 11:33 PM
SaveAs Stan Halls Excel Worksheet Functions 5 November 28th 06 07:51 PM


All times are GMT +1. The time now is 03:21 AM.

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

About Us

"It's about Microsoft Excel"