Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 238
Default search text files for a certain word

How do I search text files for a certain word using a macro. I need to
look for the word "SerialNo" and return the following 10 characters. I
will be repeating this for hundreds of files. For now, how do I do it
for a single file. Excel 97
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default search text files for a certain word

f = "c:\test.txt"
filenumber = FreeFile
Open f For Input As filenumber
a = Input(FileLen(f), filenumber)
Close filenumber

LookFor = LCase("SerialNo")
b = InStr(LCase(a), LookFor)
If b 0 Then
MsgBox Mid(a, b + Len(LookFor), 10)
End If

Mishell


"Fan924" a écrit dans le message de news:
...
How do I search text files for a certain word using a macro. I need to
look for the word "SerialNo" and return the following 10 characters. I
will be repeating this for hundreds of files. For now, how do I do it
for a single file. Excel 97



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 238
Default search text files for a certain word

What am I doing wrong?
I am getting
run time error 62, input past end of file
for line "a = Input(FileLen(f), filenumber)"

File is 32k in size and is not a text file.
It only works when I use file size of about 500.
--------------------------------------------------
Sub LookForNo()
Dim a As String
Dim f As String
Dim filenumber As String
f = "C:\My Documents\79.bak"
filenumber = FreeFile
Open f For Input As filenumber
'a = Input(500, filenumber)
a = Input(FileLen(f), filenumber)
Close filenumber
End Sub
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default search text files for a certain word


You file is probably binary

Open pathname For mode [Access access] [lock] As [#]filenumber

You need to change you mode to binary in the open statement


from
Open f For Input As filenumber
to
Open f For Binary As filenumber


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=170778

Microsoft Office Help

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 238
Default search text files for a certain word

Thanks Joel & Mishell


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
Help! Text word search. Michelle Excel Discussion (Misc queries) 2 September 19th 09 01:14 PM
Any way to word search in a Text Box? lbbss Excel Programming 4 December 11th 07 03:10 AM
Search text field for word GerryK Excel Discussion (Misc queries) 2 September 14th 07 03:42 PM
Use Windows 'search' to find Excel files containing 'a word or phr David Excel Worksheet Functions 1 December 15th 06 11:56 AM
trying to search 4 text in a word doc & print page? rede96 Excel Programming 1 April 2nd 04 03:01 PM


All times are GMT +1. The time now is 02:57 PM.

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

About Us

"It's about Microsoft Excel"