Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Trying to start a second line ( ie use of enter key) in an output file

Hello

I am trying to write to a file but cannot use the enter key to start a new line. I have tried char(10) and it puts a
square box. I tried every chr in a loop and the output file has no characters on the second line, therfore no enter
key. I have also tried vbkeyreturn and does nothing.

Anyone know how to work around this little problem?

Heres my code ( its been simplyfied)

Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim fs, f, ts
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CreateTextFile "c:\cd.asc" 'Create a file
Set f = fs.GetFile("c:\cd.asc")
Set ts = f.OpenAsTextStream(ForWriting, TristateFalse)
ts.write "hello"
ts.write Chr(10)
ts.write "hello"
ts.Close

Thanks in advance

Mike





  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Trying to start a second line ( ie use of enter key) in an output file

Use vbCrLf

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Susan Hayes" wrote in message
...
Hello

I am trying to write to a file but cannot use the enter key to start a new

line. I have tried char(10) and it puts a
square box. I tried every chr in a loop and the output file has no

characters on the second line, therfore no enter
key. I have also tried vbkeyreturn and does nothing.

Anyone know how to work around this little problem?

Heres my code ( its been simplyfied)

Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim fs, f, ts
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CreateTextFile "c:\cd.asc" 'Create a file
Set f = fs.GetFile("c:\cd.asc")
Set ts = f.OpenAsTextStream(ForWriting, TristateFalse)
ts.write "hello"
ts.write Chr(10)
ts.write "hello"
ts.Close

Thanks in advance

Mike







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
output to the same line in a Text file? Bernard Excel Discussion (Misc queries) 2 November 25th 09 08:12 PM
How to enter output range for Descriptive statistice Tahir Hashmi Charts and Charting in Excel 1 May 30th 08 05:52 PM
How to enter output range for Descriptive statistice Tahir Hashmi Charts and Charting in Excel 1 May 30th 08 08:12 AM
Subtotal: Totals line output basic Excel Discussion (Misc queries) 0 March 6th 07 09:28 PM
Any way to get around the 240-character line limit on text output? awp Excel Discussion (Misc queries) 3 December 14th 04 11:59 PM


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