View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
goepf[_8_] goepf[_8_] is offline
external usenet poster
 
Posts: 1
Default Save sheet as .TXT out of Workbook


I would like to save a sheet as .TXT out of a workbook. This works fine
but if:

I have several workbooks open and I switched between the workbooks by
minimizing them (in stead of using the menu "window") the code doesn't
work properly because the copied sheet is not the active sheet and the
code will save the original workbook as a .TXT...

code:
Sheets("BESPRO MT").Select 'sheet to copy and save as .txt
Sheets("BESPRO MT").Copy
DLSfile = "DL72112.txt"
ActiveWorkbook.SaveAs FileName:=path & DLSfile, FileFormat:=xlText,
CreateBackup:=False
ActiveWindow.Close 'should close dl72112.txt but see problem above...
Windows(FileName).Activate
Sheets("BESPRO MT").Delete


I tried with maximize window and also with activate but it didn't
work...

any idea?


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements