Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to convert a dotted line to a solid line in a line graph Sharlz Charts and Charting in Excel 1 January 14th 09 04:51 AM
need formula to apply to entire column not just one line Maggie Excel Worksheet Functions 2 July 16th 08 10:38 PM
Average line across entire chart [email protected] Charts and Charting in Excel 1 July 24th 06 09:33 PM
If value in column is yes; entire line turns red Geert_Pick Excel Discussion (Misc queries) 2 March 3rd 06 07:47 AM
Excel 2000 Hanging while reading large file with Line Input Jacques Brun Excel Programming 4 February 21st 04 05:05 PM


All times are GMT +1. The time now is 12:53 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"