Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Reads entire *.txt file into string opposed to a desired line by line input.
I have a text file of html source code (acquired using openurl) that I
want to read into Excel through VBA. My problem in the entire file is read into a string; I want to evaulate the file line by line. The text file contains a character that resembles a rectangle standing on end that is understood in Wordpad as a carraige return - i think. If I open the source code text file in Wordpad and save it as a DOS text file, I can read the file just fine in Excel using VBA. How can I programmatically resolve this issue? thx. Edward |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Reads entire *.txt file into string opposed to a desired line by line input.
Hi Edward,
ej_user wrote: I have a text file of html source code (acquired using openurl) that I want to read into Excel through VBA. My problem in the entire file is read into a string; I want to evaulate the file line by line. The text file contains a character that resembles a rectangle standing on end that is understood in Wordpad as a carraige return - i think. If I open the source code text file in Wordpad and save it as a DOS text file, I can read the file just fine in Excel using VBA. How can I programmatically resolve this issue? You should be able to use the Split function with a vbCrLf delimeter. Here's an example using IE automation: Sub Demo() Dim ie As Object Dim sWholeFile As String Dim asLineByLine() As String Dim lLine As Long Set ie = CreateObject("InternetExplorer.Application") ie.Navigate "http://www.longhead.com/" Do While ie.Busy And Not ie.ReadyState = 4 DoEvents Loop sWholeFile = ie.Document.body.innerhtml ie.Quit Set ie = Nothing asLineByLine = Split(sWholeFile, vbCrLf) For lLine = LBound(asLineByLine) To UBound(asLineByLine) Sheet1.Cells(lLine + 1, 1).Value = asLineByLine(lLine) Next lLine End Sub -- Regards, Jake Marx MS MVP - Excel www.longhead.com [please keep replies in the newsgroup - email address unmonitored] |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Reads entire *.txt file into string opposed to a desired line by line input.
Thanks Jake for providing me with a solution. The sample code is also greatly appreciated. regards, Edward *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Reads entire *.txt file into string opposed to a desired line by line input.
Edward Glover wrote:
Thanks Jake for providing me with a solution. The sample code is also greatly appreciated. No problem, Edward - glad to help out! -- Regards, Jake Marx MS MVP - Excel www.longhead.com [please keep replies in the newsgroup - email address unmonitored] |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to convert a dotted line to a solid line in a line graph | Charts and Charting in Excel | |||
need formula to apply to entire column not just one line | Excel Worksheet Functions | |||
Average line across entire chart | Charts and Charting in Excel | |||
If value in column is yes; entire line turns red | Excel Discussion (Misc queries) | |||
Excel 2000 Hanging while reading large file with Line Input | Excel Programming |