Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Opening Text Files Through Notebook

Hello all

Was hoping someone could help with this. Not really familiar with VBA
or sure if this is possible. Within VBA I wanted to open Notebook the
application, and then open a text file in Notebook. I will eventually
want to loop through all .txt files within the specified folder and
search for href tags. All these .txt files are source code files for
a website, and I'm trying to search for 3rd party websites. So
essentially...I want to open Notebook, open the first file, search the
file for href tags, close the file, open the next...

Any help would be really great! thanks!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Opening Text Files Through Notebook

Mark,

The sub below will search all files in the specified folder for the word href. It will write the
filenames and lines out to the active worksheet.

HTH,
Bernie
MS Excel MVP

Sub CheckTextFilesForHREFs()
Dim WholeLine As String
Dim myPath As String
Dim workfile As String
Dim myR As Long

myPath = "C:\Excel\Text Files\"
workfile = Dir(myPath & "*.txt")

Do While workfile < ""
Open myPath & workfile For Input Access Read As #1
While Not EOF(1)
Line Input #1, WholeLine
If InStr(1, WholeLine, "href") 0 Then
myR = Cells(Rows.Count,1).End(xlUp).Row + 1
Cells(myR,1).Value = workfile
Cells(myR,2).Value = WholeLine
End If
Wend
Close #1
workfile = Dir()
Loop

End Sub


"Mark" wrote in message
...
Hello all

Was hoping someone could help with this. Not really familiar with VBA
or sure if this is possible. Within VBA I wanted to open Notebook the
application, and then open a text file in Notebook. I will eventually
want to loop through all .txt files within the specified folder and
search for href tags. All these .txt files are source code files for
a website, and I'm trying to search for 3rd party websites. So
essentially...I want to open Notebook, open the first file, search the
file for href tags, close the file, open the next...

Any help would be really great! thanks!



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
Opening text files Sandy5590 Excel Discussion (Misc queries) 0 October 15th 09 04:35 PM
Opening text files Dan R. Excel Programming 2 April 17th 07 08:30 PM
Help, My Notebook pages are not in my notebook Heidi H Excel Discussion (Misc queries) 1 January 1st 07 09:34 PM
Trouble opening second notebook Molly Excel Discussion (Misc queries) 1 December 8th 04 03:48 AM
Opening text files Jason Excel Programming 1 March 1st 04 02:23 AM


All times are GMT +1. The time now is 12:45 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"