01-05-2011, 05:56 PM
Saket,
I tried same but It is displaying the default fonts....
E.g. Word contains "this is Rahul" but following code dispplay the formatting of "this" not "Rahul"
I tried same but It is displaying the default fonts....
E.g. Word contains "this is Rahul" but following code dispplay the formatting of "this" not "Rahul"
Code:
Set oWord = CreateObject("Word.Application")
Set oDoc = oWord.Documents.Open("C:\test.docx")
searchString = "Rahul"
For p = 1 To oDoc.Paragraphs.Count
startRange = oDoc.Paragraphs(p).Range.Start
endRange = oDoc.Paragraphs(p).Range.End
Set tRange = oDoc.Range(startRange, endRange)
tRange.Find.Text = searchString
tRange.Find.Execute
If tRange.Find.Found Then
msgbox "Word found in the document -->"& searchString
End If
Dim oSelection
Set oSelection = oWord.Selection
msgbox oSelection.Font.Name
msgbox oSelection.Font.Size
Next
oDoc.Close
oWord.Quit
Set oDoc = Nothing
Set oWord = Nothing