LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 312
Default Save sheet as .txt

Hi. I am doing an EDI transfer into our ERP system, and need to convert a
sheet in excel into a text file. I have code to take the sheet, copy it to
another workbook, and save the file as a .txt. This works fine. When I run
the EDI transfer, I get an error. (I don't expect any of you to know why
I'm getting the error!) But here's where it gets strange - If I manually
highlight and copy the contents of the excel sheet, and past that into
notepad, and then run that .txt file through the EDI, it works!

Upon initial inspection of the 2 files, they look identical! Does anyone
know why 1 file saved as a .txt would be different in any way than a
manually created .txt file?

Overriding question - how can I automate manually copying the contents of
the excel sheet and pasting into notepad? The code I have is below.
Thanks!

Sub Saveastxt()

Dim sh As Worksheet

Set sh = Worksheets("EDI Data")
sh.Copy

'Need this line because sh.Copy truncates each cell at 256 characters
sh.Range("A1:A" & sh.Range("A65536").End(xlUp).Row).Copy
Destination:=ActiveWorkbook.Worksheets("EDI Data").Range("A1")

ActiveWorkbook.SaveAs Filename:="\\server\folder\Data" & Format(Now,
"mdyyhmm") & ".txt" ', FileFormat:=xlText
ActiveWorkbook.Close SaveChanges:=False

End Sub


 
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
Save, save as, page setup dimmed out in unprotected excel sheet? ccKeithJ Excel Discussion (Misc queries) 3 December 14th 07 07:07 PM
How to save only row changes to a new sheet J Sears Excel Discussion (Misc queries) 1 September 22nd 06 07:50 PM
save as w/sheet TUNGANA KURMA RAJU Excel Discussion (Misc queries) 4 September 16th 06 08:05 PM
Q: save a sheet to a file JIM.H. Excel Discussion (Misc queries) 2 October 25th 05 03:12 PM
Save sheet? Heine Excel Worksheet Functions 7 March 9th 05 10:55 AM


All times are GMT +1. The time now is 11:01 AM.

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"