I am trying to write a VBA procedure that searches for usernames in a text file to find the IP address of a user. So, for example, given the input below, if I'm looking Chris Trucker, I want to see 192.168.130.22messages in the window.
> 192.168.2.151,Super Fly,ABC\Flys,2012-05-18 16:11:29
> 192.168.2.200,Rain,ABC\rain,2012-05-17 15:42:05
> 192.168.2.210,Snow,ABC\Snow,2012-05-16 08:24:39
> 192.168.2.78,Wind,ABC\wind,2012-05-02 19:24:06
> 192.168.130.21,Mike Jordan,ABC\Jordanm,2012-05-18 17:28:11
> 192.168.130.22,Chris Trucker,ABC\Truckerc,2012-05-18 17:28:11
> 192.168.130.23,Chris Jackson,ABC\JacksonC,2012-05-18 17:04:39
Tried the following, but this is VBScript
Const ForReading = 1
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Pattern = "JacksonC"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("\\server\tsusers\Users.txt", ForReading)
Do Until objFile.AtEndOfStream
strSearchString = objFile.ReadLine
osakapc = Left(strSearchString,14)
Set colMatches = objRegEx.Execute(strSearchString)
If colMatches.Count = 1 Then
For Each strMatch in colMatches
Next
End If
Loop
source
share