Prev: Insert a square in a cell with VBA
Next: can anybody send me complete list of MS Office Object model ?
From: Fan924 on 16 Jan 2010 20:18 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
From: Mishell on 16 Jan 2010 23:59 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(a)yahoo.com> a �crit dans le message de news: 2abad4b9-506a-430f-be21-6e18dae03752(a)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
From: Fan924 on 17 Jan 2010 06:49 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
From: joel on 17 Jan 2010 09:58 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="http://www.thecodecage.com"]Microsoft Office Help[/url]
From: Fan924 on 22 Jan 2010 00:37
Thanks Joel & Mishell |