| || |
Change the font style of a text file
I tried searching forum for this but I could not get an answer.
I am trying to compare two text file and if a particular line doesn't match , I want to change the font to be bold or probably chnage the font size.
Currently as an alternate , I am writing the changes into the third file.
The code looks like
Public Function ComparetextFiles(path1, file1, file2,file3)
Const ForReading = 1, ForWriting = 2, BinaryCompare = 0
Dim fso, MyFile1, MyFile2, comp, ln1, ln2
y = path1 & "\\" & file1
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile1 = fso.OpenTextFile(path1 & "\\" & file1, ForReading)
Set MyFile2 = fso.OpenTextFile(path1 & "\\" & file2, ForReading)
Set MyFile3 = fso.OpenTextFile(path1 & "\\" & file3, ForWriting)
Do While ((MyFile1.AtEndOfStream <> True) OR (MyFile2.AtEndOfStream <> True))
ln1 = MyFile1.ReadLine
ln2 = MyFile2.ReadLine
comp = strcomp( ln1, ln2, BinaryCompare)
If (comp <> 0) then
MyFile3.write "Actual =" & ln1 & " and Expected = " & ln2 & vbcrlf
CompareFiles = 1
Re: Change the font style of a text file
Text file do not support colors. You need to use Microsoft Word APIs (Word.Application) to do something like this. Where you will have the ability to control color and other things as well.