I believe using Write on the OP's text file will encase the entire file in
quote marks. And, if the text contains quoted text within it, I believe
there will be some problems around those embedded text strings also. I
decided early on (maybe 25 years ago or so) to avoid using Write to put data
into a file because of what I considered at the time to be some odd
behaviors... in any event, I've found Print to do all I have ever needed
across the years, so I've always stuck with it when I need to write out to a
file.
--
Rick (MVP - Excel)
"Jacob Skaria" <(E-Mail Removed)> wrote in message
news:4FD88C29-BF00-4337-AA9C-(E-Mail Removed)...
> One more, you can also use...
>
> Write #1, cDataNoCrLf
>
> If this post helps click Yes
> ---------------
> Jacob Skaria
>
>
> "Francis Ang" wrote:
>
>> Thank you, Rick,
>>
>> It works! The semi-colon did the trick.
>>
>> Thank you.
>>
>> "Rick Rothstein" wrote:
>>
>> > Print statements put a CarriageReturn/LineFeed combination at the end
>> > of
>> > each line it prints by default. You can suppress this default
>> > functionality
>> > by placing a semi-colon at the end of the Print statement. Try it this
>> > way...
>> >
>> > Print #2, cDataNoCrLf;
>> >
>> > Notice the semi-colon at the end of the statement.
>> >
>> > --
>> > Rick (MVP - Excel)
>> >
>> >
>> > "Francis Ang" <(E-Mail Removed)> wrote in message
>> > news:848E7D5F-6EBD-4C9A-928F-(E-Mail Removed)...
>> > > Hi Joel,
>> > >
>> > > Thank you for responding so quickly. As requested, here is the code
>> > > I
>> > > wrote -
>> > >
>> > > Sub CarriageRmv()
>> > > Open "C:\abc.txt" For Input As #1
>> > > Do While Not EOF(1)
>> > > Line Input #1, cData
>> > >
>> > > cDataNoCrLf = Replace(cData, vbCrLf, "")
>> > >
>> > > Open "C:\NoCrLF.txt" For Append As #2
>> > > Print #2, cDataNoCrLf
>> > > Close #2
>> > >
>> > > If EOF(1) Then
>> > > Close #1
>> > > Name "C:\NoCrLF.txt" As "C:\NoCrLf.hex"
>> > > Exit Sub
>> > > End If
>> > > Loop
>> > > End Sub
>> > >
>> > >
>> > > "joel" wrote:
>> > >
>> > >> I would like to see your code. Especially the way you are opening
>> > >> the
>> > >> file.
>> > >> thre are some defaults on how the file is being opened. You ca open
>> > >> the
>> > >> file
>> > >> as text or Unicode. You may be opening the file as unicode which
>> > >> really
>> > >> are
>> > >> 16 bit characters instead of 8 bit characters.I would also like to
>> > >> see
>> > >> your
>> > >> replace statement.
>> > >>
>> > >> "Francis Ang" wrote:
>> > >>
>> > >> > I am using REPLACE command to remove carriage return and line feed
>> > >> > from
>> > >> > a
>> > >> > text file; but when I rename the text file from 'abc.txt' to
>> > >> > 'abc.hex',
>> > >> > the
>> > >> > carriage return mysteriously reappears.
>> > >> >
>> > >> > I tried using the REPLACE command on 'abc.hex' file but it is not
>> > >> > working.
>> > >> > REPLACE seems to work on text file only.
>> > >> >
>> > >> > Any assistance will be greatly appreciated.
>> > >> >
>> > >> > Thank you.
>> > >> >
>> > >> >
>> >
>> >
|