How to create unix format text files i.e. without "^M"

T

tmuhammad

HiFolks
I am creating some text reports using Scripting.FileSystemObject which are
put on the unix box for end user downloads and when these reports are opened
in unix these appear to have "^M" chracter at the end of each line, is there
a way to avoid those using VBA

Thanks
 
T

TC

Different operating system families, use a different character or character
sequence to indicate the end of each line inside a "flat text" file.

Windows boxes use carriage return (CR - &h0d - ^M), linefeed (LF - &h0a -
^J), or both (in that order). Not sure what Unix boxes use. Your flat file
contains a termninating carriage return which the Unix box is displaying as
a data character. You need to create the text file using the correct line
terminator (whatever that is) for Unix.

HTH,
TC
 
A

Alp Bekisoglu

A VERY amateurish approach maybe but:
Mid(yourOutputLineString, 1, Len(yourOutputLineString)-2)
could eliminate tha last two characters.
Sorry if it doesn't make any sense...

Alp
 
J

John Nurick

Hi,

As far as I know the choice is between filtering the \x0d out as you
move the files onto the Unix box, or using the antique Basic file I/O
statements, like this:

Sub TestBin()
Dim S As String
Dim lngFN As Long

lngFN = FreeFile()
Open "C:\temp\vbtest.txt" For Binary As #lngFN
S = "This is a test" & Chr(10) & "Second line"
Put #lngFN, , S
Close #lngFN
End Sub

I don't know whether these are Unicode-aware.
 
T

Tim Ferguson

when these reports are opened
in unix these appear to have "^M" chracter at the end of each line, is
there a way to avoid those using VBA

Easiest way is to write a one-line perl script on the unix box and let the
real computer do the work... :)


Tim F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top