Hi all
I want to find some text by reading from a text file. I had stored the below information in a text file
and want to read it thro' code and find the same in a word document. Here instead of hyphen i want to store the ascii value and retrieve from the file. Please have a look at my code.Code:[0-9]{1,}[" & chr(45) & "][0-9]{1,}
the chr value of hyphen didn't change in that string variable. Plz advice me..Code:Private Sub ReadFromFile() Dim sStoredText As String Dim sFilePath As String, aTest() As String Dim sFile As File, ReadFile As TextStream Dim rngTest As Range sFilePath = "D:\Test.txt" Set FSO = New FileSystemObject If FSO.FileExists(sFilePath) Then Set sFile = FSO.GetFile(sFilePath) Set ReadFile = sFile.OpenAsTextStream(ForReading) Do While Not ReadFile.AtEndOfStream sStoredText = ReadFile.ReadLine Loop End If Set rngTest = ActiveDocument.Range rngTest.Find.ClearFormatting rngTest.Find.Execute findtext:=sStoredText, MatchWildcards:=True If rngTest.Find.Found Then rngTest.Select MsgBox sStoredText End Sub




Reply With Quote