From: Pegasus (MVP) on 27 Jan 2009 01:50 "Codeblack" <Codeblack(a)discussions.microsoft.com> wrote in message news:9576CC20-9D38-4F87-9374-2C4F4BA01F3C(a)microsoft.com... > Thanks for your suggestion. But i cannot use VBA in this case as the files > in > which i search for keywords is not constant and there are hundreds of > files > which in need to search. Any inputs please. Here is the example from the help file I mentioned. Which part are you having problems with? Function WriteLineToFile Const ForReading = 1, ForWriting = 2 Dim fso, f Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.OpenTextFile("c:\testfile.txt", ForWriting, True) f.WriteLine "Hello world!" f.WriteLine "VBScript is fun!" Set f = fso.OpenTextFile("c:\testfile.txt", ForReading) WriteLineToFile = f.ReadAll End Function
From: Codeblack on 27 Jan 2009 11:06 Thanks MVP. I know how to write the data to text file but i dont know how to retrive/copy the data from the excel cell when a match is found.
From: Pegasus (MVP) on 27 Jan 2009 11:42 "Codeblack" <Codeblack(a)discussions.microsoft.com> wrote in message news:A42B1190-DAF5-4AA6-85ED-85849724896D(a)microsoft.com... > > Thanks MVP. I know how to write the data to text file but i dont know how > to > retrive/copy the data from the excel cell when a match is found. > Try this modification to your code. Note that I dropped one line! objWorkSheet.Activate Set objCell = objWorkSheet.Cells.Find(strSearchTerm, objWorkSheet.Cells(1, "A"), xlFormulas, xlPart, xlByRows, xlNext, boolMatchCase) x = objCell.value
From: Codeblack on 27 Jan 2009 12:22 I Tried this but it is not retriving any value from the cell. I did tried writing the value using Wscript.echo and it was not printing anything.
From: Matthias Tacke on 27 Jan 2009 12:22 Codeblack wrote: > Thanks MVP. I know how to write the data to text file but i dont know how to > retrive/copy the data from the excel cell when a match is found. > > IIUR all you have to do is to append the found Row number to strResults strResults = strResults&VbCrLf&objWorkSheet.Name&" Row:"&objCell.Row And you should write that variable to a file before exiting th script. Oh, and use a simple searchstr for testing like strSearchTerm = "abc" With this and a prepared test.xls I got: Tabelle1 Row:3 Tabelle2 Row:4 Tabelle3 Row:6 -- HTH Matthias
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 Prev: Help desperately needed. Next: Connecting to Win32_DFSTarget on Windows Server 2008 |