View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JaimeVasquez JaimeVasquez is offline
external usenet poster
 
Posts: 4
Default Get certain words from a line into a cell

On Apr 17, 9:48 am, Mark wrote:
Hello

Just hoping someone can send me in the right direction here with a
method that might work here. I am extracting data from text files
based on finding a certain word. If found, the whole line in the text
doc will be pasted into a row in excel. There are certain things in
these rows like just the web address, or page title, that I want in
the Excel doc rather than the entire line. Would this be parsing
usign tokens or something? Any help or pointers would be great!
Thanks a lot

Mark


Try with something like this:

Sub GetTitle()
Dim sLine As String, iStart As Integer, iEnd As Integer, cTitle As
String

sLine = "<head id=ctl00_ctl00_Head1<base href=http://
www.sqlteam.com/default.aspx /<meta http-equiv=Content-Type
content=text/html; charset=utf-8 /<link rel=SHORTCUT ICON href=http://
www.sqlteam.com/favicon.ico /<link rel=alternate type=application/rss
+xml title=SQLTeam.com -- SQL Server Information href=http://
feeds.sqlteam.com/sqlteam /<titleGenerating ADO Parameters with
Information Schema Views - SQLTeam.com</title<link rel=stylesheet
href=sqlteam2.css type=text/css /<link rel=stylesheet href=csharp.css
type=text/css /"

iStart = InStr(1, sLine, "<title", vbBinaryCompare) +
Len("<Title")
iEnd = InStr(1, sLine, "</title", vbBinaryCompare)

cTitle = Mid(sLine, iStart, iEnd - iStart)
MsgBox cTitle, , "Title"

End Sub

This extracts the page title, something similar can be done to extract
the url.

notice that the line used is not a valid html text, all double quotes
have been removed to show the example.

source of example: http://www.sqlteam.com/article/gener...n-schema-views


HTH

Jaime Vasquez