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
0
Fan924
1/17/2010 1:18:56 AM
excel.programming 6508 articles. 2 followers. Follow

4 Replies
768 Views

Similar Articles

[PageSpeed] 37

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" <a924fan@yahoo.com> a �crit dans le message de news: 
2abad4b9-506a-430f-be21-6e18dae03752@e27g2000yqd.googlegroups.com...
> 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 


0
Mishell
1/17/2010 4:59:58 AM
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
0
Fan924
1/17/2010 11:49:43 AM
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/showthread.php?t=170778

[url=&quot;http://www.thecodecage.com&quot;]Microsoft Office Help[/url]

0
joel
1/17/2010 2:58:51 PM
Thanks Joel & Mishell
0
Fan924
1/22/2010 5:37:54 AM
Reply:

Similar Artilces:

Bought Pub 2003 now it won't open my Pub 2003 file
I just bought Publisher 2003 yesterday. I spent 3 hours creating a project. I tried to laod the saved project and got the message "Publisher can not open file. I tried open pun 97 files with the same result. I've used Publisher 2.0, 97 for years. What am I missing? Most likely you are running Norton Anti-Virus. Norton AV can actually break a Publisher file rendering it unusable. You need to disable script-blocking and possibly the Office plug-in components of Norton AV. Refer to http://www.davidbartosik.com/pub2002/pub2002_issues.htm -- David Bartosik - MS MVP for Publisher help...

How to convert Quicken QFX files?
I am unable to convert a Quicken QFX file to be used in Microsoft Money 2003. Any ideas? In microsoft.public.money, Greg wrote: >I am unable to convert a Quicken QFX file to be used in >Microsoft Money 2003. Any ideas? Have you tried File->Import? ...

Can't open .pub files either
I have installed / unistalled / installed / uninstalled Publisher 2003 several times and have the same problems others seem to have. I can create and save a .pub file but cannot open them. Get the "cannot find file" message followed by the "cannot open" message. I have loaded the same Publisher program on another computer in our office and it works fine. To save time I should said ahead of time that we: DO NOT use Norton Antivirus DO use Norton Internet Securities which have been set to "allow scripts" Please help! If I cannot re-open and re-edit .pub fi...

Search between two dates
Hi everyone I've got information in a SQL Server Database. I'm viewing the data using MS Excel, e.g Data, Get External Data, Create New Query (on the toolbar). Now using the wizard I have got to Microsoft Query. What I want the system to do is..... When I open the spreadsheet a pop up box appears where the user types in the FROM date, then a second pop up box appears where the user types in the TO date. The values that are shown on the spreadsheet are the values between the two dates (including the FROM and TO dates). Is this quite easy? Thanks for any help David -- David4...

enumerating file on a directory
hi, How can i enumerate files on a directory based on a filter like "*.h" and store the result on an array on VC++. tnx, hope you guys can help. I choose Polesoft Lockspam to fight spam, and you? http://www.polesoft.com/refer.html Look For CFileFind Class if working in MFC or FindFirstFile FindNextFile or FindClose if you project based on Win32 -- cheers, Alok Gupta Visit me at http://alok.bizhat.com "lawrence" <las@cybees.com> wrote in message news:#NvsWCRXFHA.2796@TK2MSFTNGP09.phx.gbl... > hi, How can i enumerate files on a directory based on a filter...

Log files in Great Plains 8.0
We use a web based program to import orders from our website into Great Plains. We have recently come across some errors where invoices show up with no associated order or customer information. The only thing that shows on these invoices is item information. I believe these invoices are generated somehow by a glitch in the import we do for our web orders. Is there a log file somewhere in GP where I can see what information was entered based on date? Or if anyone else has experienced this problem before, am I correct in my assumption that the "ghost" invoices are being caused by ...

Importing large tab-delimited text files?
I deal with very large data sets that are in tab-delimited .txt format. Many times, there are more than 256 columns of data. The Microsoft Knowledge Base had an article titled "Sample Macro to Import Data with More Than 256 Fields or Columns". This could do the trick for me if I could modify the macro to accomodate tab-delimited formats. Q1: Could anyone tell me how to modify the macro described above for tab-delimited .txt files? Q2: Does anyone know of a bulk file conversion utility that would change a tab-delimited text file to a CSV format? Thanks a bunch, Mark R-S Ma...

How do I print a text file ?
Hi, I am new to the group and wonder if any of you could offer any advice. I am trying to print a text file directly from my visual c++ application to the default printer without displaying the print dialog What is the best way of doing this ? If it is not possible to print directly from a text file, what commands to I use in between CDC::StartPage () To print the following Hello, my name is Joe Bloggs How are you I hope you can help with this problem etc..... CDC::EndPage () Thanks in advance Paul Paul, More info on printing than you can comfortably shake a stick at: http://www....

Outlook pst file
My original pst file was about 30 mb in size. Somehow it is corrupted and showing only 30 kb in size. I am not able to recover my previous info. Is there any way to retrieve info from this pst. You could try the inbox repair tool, scanpst.exe David "Ajay" <ajayget@indiatimes.com> wrote in message news:07e301c358de$6534d0d0$a101280a@phx.gbl... > My original pst file was about 30 mb in size. Somehow it > is corrupted and showing only 30 kb in size. I am not able > to recover my previous info. Is there any way to retrieve > info from this pst. ...

Open File Dialog Help
I am trying to set the m_ofn.lpstrInitialDir to "My Music" on an open file dialog, but can't seem to get it to work right. I would like it to default to the c:\documents and settings\user\My Documents\My Music, regardless of the machine the application is running on. The project is being built using Visual C++ 6.0 Professional, on a Windows 2K machine, but may be running in any Windows environment. Thanks, SHGetSpecialFolderPath(CSIDL_PERSONAL) gets you to My Documents ...

Published 2000 pictures make file sizes too big
I have scanned pictures using Microsoft Photo/Draw. The pictures are around 250 KB but when I put them in my Published document, the file grows to 14,000KB. I can't email them or save them on a floppy. How can I get this file size down You may have to convert the file to a pdf format. Publisher just make humongous files. You have several choices when it comes to a pdf converter program from freebees to Adobe Acrobat. The later is on the spendy side and the freebees may disappoint you. My choice after comparing 5 pdf converter programs was PDF-XChange, a very nice commercial produc...

Copy a file with only values no formulas
Is there an easy way to copy a workbook so that it only has the values and not the formulas? Thank you. -- Lee Coleman Right click on a sheet tab and select all sheets. Then select all cells on the active sheet. Do a copy, then Edit, paste special, values. Right click on a sheet tab and select ungroup sheets. Save the workbook under a different name!!!! Bob Flanagan Macro Systems http://www.add-ins.com Productivity add-ins and downloadable books on VB macros for Excel "Lee Coleman" <lee@nospam.jjlgreenhouses.com> wrote in message news:OIOx4$FeHHA.4020@TK2MSFTN...

No files selected in openfiledialog
How can I test for openfiledialog OK clicked without any files being selected? (I'm using it with multiple select as true.) I've tried if openfiledialog1.filenames = nothing then ... and if ubound(openfiledialog1.filenames) = -1 then ... but both these give compile errors. Grateful for advice. Am 11.05.2010 15:46, schrieb simonc: > How can I test for openfiledialog OK clicked without any files being > selected? (I'm using it with multiple select as true.) > > I've tried > > if openfiledialog1.filenames = nothing then ... > &g...

Error searching an additional mailbox
Greetings, I have several users, who, in addition to their own mailbox, mount a second mailbox for storage of certain emails. Recently, several of these users have tried to do searchs on one of the folders in that mailbox and receive a dialog box stating There are too many Find Public Folders dialogs open. You must close them in order to use the Advanced Find. Do you want to close them now? These are all Outlook 2002 users running against an Exchane 5.5 server. Anyone seen this problem before? K ...

PROBLEM SIZING A TEXT BOX IN A FORM
Access 2007/vista I have a form in which I cannot adjust the text boxes INDIVIDUALLY. I click on a text box and it becomes surrounded by an orange border, indicating it is selected. But when I size it smaller or larger, all the other text boxes in the form move in tandem. I have not encountered this before and am baffled. Ideas? -- William ...

Can you change the way quick parts and/or auto text displays?
Is there a way to change the look of the drop down menu for quick parts and auto text so it does not take up so much space? Something like it looked in 2003? Assuming that you have discovered the building block organizer - see http://gregmaxey.mvps.org/Buiild_Employ_Custom_BB_Gallery.htm Like 2003 it ain't! -- <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org <>>< ><<> ><<&...

creating text box dynamically in ms access
can any body please tell me the code to create text boxes dynamically or else please give me the link abt that information Thanq See help on CreateControl In general, this is only useful if you are creating some kind of wizard form that creates whole forms for end users. You don't want to be creating text boxes on the fly for a normal form. -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "ravindar thati" <ravindarjobs@gmail.com> wrote in mes...

Relative File locations
I have a program that opens file #1 in folder XYZ. In this file is a reference to another file #2 in another folder. Is there a way to reference file #2 so if I put file #2 and file #1 in the same folder, the reference will always be made to the folder that contains the file #1, no matter where I may relocate it? Thanks, ...

text conversion to number on select query
Hi, In a Select Query I'm joining 2 tables by Item ID (unique value, similar to Social Security Number) but 1 table created by IT has Item ID as a "number" value and the other table has it as a "text" value. How can I in a Select Query, create a formula that can either have the text as a number value and vice versa so i can link the 2 without getting "type mismatch in expression." I think I can use Cdbl Value or something like that in the formula but not sure. Thanks! "inspirz" wrote:subed going to jail > Hi, > ...

Answer file local admin password
Hi, I am trying to apply a local admin password to all PC's during my ghost roll out. Everthing works from my answer file with the only exception the local admin password is not applied. Here is the current part of my answer file [GuiUnattended] AdminPassword="R0ver" EncryptedAdminPassword=NO ...

Advanced Search in Outlook 2003
I'm looking for a way to search for any sent messages that are over 90 days of age. I'm able to manually create the criteria: Search in: 'Sent Items', where item is 'Sent on or before' and a manually entered date but can't seem to find a automatic way for the 'Value'. Online help gives no reference on how to create a condition of 'Over xx Days'. ...

Schedueled Auto Send .xls File to Receipients
I have an MS2007...I have a progress tracking excel spreadsheet that I must send to certain associates on a biweekly basis. What functionality exists or coding is reqiuried for my document to be automatically sent to selected receipients on a scheduled basis until the project is complete? ...

Word won't quit
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel Just installed Office 2008 for Mac, ran software update and installed version 12.2.3 -- Running OSX 10.6.2 on a MacBook Pro. <br> Word opens and seems to be working well, but when asked to Quit it gives an error message -- &quot;A file error has occurred. Check your network connections or make sure the disk is properly inserted and not defective. (Normal.dotm)&quot; -- When I click OK, I get a chance to report the problem. Then as long as I uncheck the option to recover my work and restart, it wil...

search public folders
We have exchange 2003 and Outlook 2003 and 2007. Our public folders have over 1000 documents, public contacts, etc/ Is there a way - builtin or 3rd party - to do a search so all materials - documents, contacts, etc - that match will show up? The current serach in Outlook doesnt seem to work with public folders. thanks, Raul Rego Do you mean searching across multiple public folders in one search? That's not supported by the store provider for public folders. To search like that Outlook must create a temporary search folder. PST files and Exchange mailboxes support search folder...

EXCEL Decimal changes during WORD Merge
Why does Excel change 16 cents into .1599999 in a merge process Have not had this problem until we upgraded to 2003????? I have tried different cell formats in Excel Number - currency - accounting - custom - all with the 2 decimal places text - but rather not lose numeric functions (am re-entering figures by hand and using text format today to finish merged letters - - ugghhh!) Help? I have had a similar problem in previous versions of Excel as well, not just Office 2003. Is the data in Excel coming from an outside source like a non Microsoft database query? I run into this probl...