Re: quick question by ekkehard
ekkehard
Wed Jun 20 17:08:31 CDT 2007
S Moran schrieb:
> try:
>
> strContent = objFile.ReadAll
> strContent = Replace(strContent, vbCrLf, " ")
>
Why? If strContent gets filled by objFile.ReadAll then
strContent = Replace( objFile.ReadAll, vbCrLf, " " ) can't fail.
>
> <drk360@hotmail.com> wrote in message
> news:1182349272.436380.65830@g37g2000prf.googlegroups.com...
>> I need some help with a simple code that can read a text file and save
>> the contents as a string under a variable name. And have the contents
>> of the text file appear on one line of string...
>>
>> what i tried was:
>> Set objFSO = CreateObject("Scripting.FileSystemObject")
>> Set objFile = objFSO.OpenTextFile("C:\temp1\test.txt", ForReading)
>> strContent = Replace (objFile.ReadAll,vbCrLf," ")
>>
>> but strContent is not a string, therefore im unable to manipulate it
>>
>> ur help is greatly appreciated
>>
Do you use "On Error Resume Next"? If yes, disable it. Double check
the file specification and the variable/constant "ForReading".
>