Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Ed,
You might have to declare another variable to refer to a Text Stream object, then include an additional line of code to open the file that way. Also, you should use the AtEndOfStream property on the Text Stream object to prevent running past the end of the file. Also, how do you plan to read multiple lines of text file into a single Contents variable? Each line would probably have to be added with a NewLine string (vbNewLine) (or vbCrLf) embedded between it and the previous contents. So your code (untested revision) might look like the following: Dim FSO As Object, File As Object, Contents As String Dim TS as Object 'Text Stream object. Set FSO = CreateObject("Scripting.FileSystemObject") Dim strFName As String Dim strFPath As String strFPath = ActiveWorkbook.Path & "\" strFName = strFPath & "About.txt" Set File = FSO.OpenTextFile(strFName) Set TS = File.OpenAsTextStream(1, 0) 'Open the text file for reading in ASCII format. Contents = "" Do While Not TS.AtEndOfStream Contents = Contents & TS.ReadLine & vbNewLine Loop TS.Close 'Now do something with Contents. -- Regards, Bill |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
FILE CAN ONLY OPEN AS READ ONLY | Excel Discussion (Misc queries) | |||
Excel file won't open because it' a read only file when it is not | Excel Discussion (Misc queries) | |||
How to Open file as read only | Excel Programming | |||
Open File Read Only | Excel Programming | |||
File in use open read only | Excel Programming |