Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Save Worksheet as Text File

Hello,
I would like to be able to open a .txt file in Excel VBA using the Text
Import Wizard. The file is Tab Delimited and used the "~" or "Other". Once
open I want to be able to change some values in fields and then save it with
the changes as a text file.

Can anyone tell me how I would save the file as a .txt file with the changes
I made?
For some reason there are four blank columns at the beginning and I need to
keep those in place when saving back to a text file.

I used the macro record feature and the code to open the text file with the
Import Wizard looks like:

Workbooks.OpenText Filename:= _
"C:\leasepayment.txt" _
, Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True,
Semicolon:=False, _
Comma:=False, Space:=False, Other:=True, OtherChar:="~", FieldInfo:= _
Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5,
1), Array(6, 1), Array(7 _
, 1), Array(8, 1), Array(9, 1), Array(10, 1), Array(11, 1),
Array(12, 1), Array(13, 1), Array _
(14, 1), Array(15, 1), Array(16, 1), Array(17, 1), Array(18, 1),
Array(19, 1), Array(20, 1), _
Array(21, 1), Array(22, 1), Array(23, 1), Array(24, 1), Array(25,
1), Array(26, 1), Array( _
27, 1), Array(28, 1), Array(29, 1), Array(30, 1), Array(31, 1),
Array(32, 1), Array(33, 1), _
Array(34, 1), Array(35, 1), Array(36, 1), Array(37, 1), Array(38,
1), Array(39, 1), Array( _
40, 1)), TrailingMinusNumbers:=True

ANY HELP WOULD BE APPRECIATED!!

THANKS!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Save Worksheet as Text File

Maybe you could use a macro that writes your data:

Earl Kiosterud's Text Write program:
www.smokeylake.com/excel
(or directly: http://www.smokeylake.com/excel/text_write_program.htm)

Chip Pearson's:
http://www.cpearson.com/excel/imptext.htm

J.E. McGimpsey's:
http://www.mcgimpsey.com/excel/textfiles.html

======
Earl's may be sufficient right out of the box. He supports lots of options.


sharonm wrote:

Hello,
I would like to be able to open a .txt file in Excel VBA using the Text
Import Wizard. The file is Tab Delimited and used the "~" or "Other". Once
open I want to be able to change some values in fields and then save it with
the changes as a text file.

Can anyone tell me how I would save the file as a .txt file with the changes
I made?
For some reason there are four blank columns at the beginning and I need to
keep those in place when saving back to a text file.

I used the macro record feature and the code to open the text file with the
Import Wizard looks like:

Workbooks.OpenText Filename:= _
"C:\leasepayment.txt" _
, Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True,
Semicolon:=False, _
Comma:=False, Space:=False, Other:=True, OtherChar:="~", FieldInfo:= _
Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5,
1), Array(6, 1), Array(7 _
, 1), Array(8, 1), Array(9, 1), Array(10, 1), Array(11, 1),
Array(12, 1), Array(13, 1), Array _
(14, 1), Array(15, 1), Array(16, 1), Array(17, 1), Array(18, 1),
Array(19, 1), Array(20, 1), _
Array(21, 1), Array(22, 1), Array(23, 1), Array(24, 1), Array(25,
1), Array(26, 1), Array( _
27, 1), Array(28, 1), Array(29, 1), Array(30, 1), Array(31, 1),
Array(32, 1), Array(33, 1), _
Array(34, 1), Array(35, 1), Array(36, 1), Array(37, 1), Array(38,
1), Array(39, 1), Array( _
40, 1)), TrailingMinusNumbers:=True

ANY HELP WOULD BE APPRECIATED!!

THANKS!


--

Dave Peterson
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
How do you save an excel file to be read as IBM-type text file ? Dee Franklin Excel Worksheet Functions 2 October 10th 06 02:46 AM
How can I save a file as a comma-delimited text file in Excel? LAM Excel Discussion (Misc queries) 1 May 3rd 05 10:24 PM
how to lmport a text file and save it as an excel file using vb s. Newbie Scriptor Excel Programming 8 December 16th 04 01:54 PM
Excel VBA - open text file, replace text, save file? Cybert Excel Programming 2 October 2nd 04 01:05 AM
Save As - Multiple Sheets fails to save as text file Ravee Srinivasan Excel Programming 2 November 10th 03 04:05 PM


All times are GMT +1. The time now is 05:55 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"