Is that workbook You are trying to copy as txt file have a
name? Yes, so:
Workbooks(name).SaveAs FileName:=path & DLSfile,
FileFormat:=xlText,CreateBackup:=False
Workbooks(name).Close
Always set context to work with workbooks!
-----Original Message-----
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
.