Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Remove last CRLF in text file

Hi there,

I want to write a string from VBA into a text file. This file is an
input file for an Unix application, i.e. LF as the last character in a
file.
The Print statement does put me a CRLF at the end of every line. I got
around this problem to first concatenate the whole string with the
chr(13) LF and at the end write it into file.
This leaves me one CRLF at the very end of the file.

How do I get rid of this?
I tried to shorten the string by one character but than the string is
too short.
I re-read and re-wrote the file omitting the last line. No way. No
idea.

Any help is appreciated.
S.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Remove last CRLF in text file

Look in Excel VBA help at the Put command.

--
Regards,
Tom Ogilvy


" wrote:

Hi there,

I want to write a string from VBA into a text file. This file is an
input file for an Unix application, i.e. LF as the last character in a
file.
The Print statement does put me a CRLF at the end of every line. I got
around this problem to first concatenate the whole string with the
chr(13) LF and at the end write it into file.
This leaves me one CRLF at the very end of the file.

How do I get rid of this?
I tried to shorten the string by one character but than the string is
too short.
I re-read and re-wrote the file omitting the last line. No way. No
idea.

Any help is appreciated.
S.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Remove last CRLF in text file

Perhaps use the Replace function to remove the CR character.

Replace(textwithCRLF, chr(10), "")

--
Hope that helps.

Vergel Adriano


" wrote:

Hi there,

I want to write a string from VBA into a text file. This file is an
input file for an Unix application, i.e. LF as the last character in a
file.
The Print statement does put me a CRLF at the end of every line. I got
around this problem to first concatenate the whole string with the
chr(13) LF and at the end write it into file.
This leaves me one CRLF at the very end of the file.

How do I get rid of this?
I tried to shorten the string by one character but than the string is
too short.
I re-read and re-wrote the file omitting the last line. No way. No
idea.

Any help is appreciated.
S.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Remove last CRLF in text file

I believe he is saying the Print is putting the CRLF, so you can't use
replace on the newly written file and doing it before writing the file
wouldn't address the problem.


The OP could also try

Print #1, strng;

instead of
Print #1, strng

or if he needs a LF on the end

Print #1, strn & vbLf;


--
Regards,
Tom Ogilvy




"Vergel Adriano" wrote:

Perhaps use the Replace function to remove the CR character.

Replace(textwithCRLF, chr(10), "")

--
Hope that helps.

Vergel Adriano


" wrote:

Hi there,

I want to write a string from VBA into a text file. This file is an
input file for an Unix application, i.e. LF as the last character in a
file.
The Print statement does put me a CRLF at the end of every line. I got
around this problem to first concatenate the whole string with the
chr(13) LF and at the end write it into file.
This leaves me one CRLF at the very end of the file.

How do I get rid of this?
I tried to shorten the string by one character but than the string is
too short.
I re-read and re-wrote the file omitting the last line. No way. No
idea.

Any help is appreciated.
S.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Remove last CRLF in text file

Replacing did not work.

But the semikolon did the trick.
Print #1, strng;

It omitted the CRLF at the end.
So I concatenated the string with a vbLn and then put a semikolon at
the end and I get what I want.
Print #1, strn & vbLf;


Many Thanks
S.

On 28 Mrz., 14:26, Tom Ogilvy
wrote:
I believe he is saying the Print is putting theCRLF, so you can't use
replace on the newly written file and doing it before writing the file
wouldn't address the problem.

The OP could also try

Print #1, strng;

instead of
Print #1, strng

or if he needs a LF on the end

Print #1, strn & vbLf;

--
Regards,
Tom Ogilvy

"Vergel Adriano" wrote:
Perhaps use the Replace function to remove the CR character.


Replace(textwithCRLF, chr(10), "")


--
Hope that helps.


Vergel Adriano


" wrote:


Hi there,


I want to write a string from VBA into a text file. This file is an
input file for an Unix application, i.e. LF as the last character in a
file.
The Print statement does put me aCRLFat the end of every line. I got
around this problem to first concatenate the whole string with the
chr(13) LF and at the end write it into file.
This leaves me oneCRLFat the very end of the file.


How do I get rid of this?
I tried to shorten the string by one character but than the string is
too short.
I re-read and re-wrote the file omitting the last line. No way. No
idea.


Any help is appreciated.
S.





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
Cut and Paste Text with CRLF into Single Cell Jim Excel Discussion (Misc queries) 1 January 10th 08 08:57 PM
Remove headers from text file Hilton Excel Discussion (Misc queries) 4 November 6th 07 03:04 PM
Change file name - remove specific text [email protected] Excel Programming 4 October 9th 06 01:49 PM
CRLF in .cvs file LMI Excel Programming 2 April 7th 06 02:31 PM
CRLF in text box Neil Miller[_2_] Excel Programming 5 January 7th 04 03:14 PM


All times are GMT +1. The time now is 12:39 PM.

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"