Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Word text formatting
#6
Solved: 10 Years, 9 Months, 1 Week ago
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"

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
Reply


Messages In This Thread
Word text formatting - by Rahull - 01-04-2011, 06:41 PM
RE: Word text formatting - by Saket - 01-04-2011, 07:19 PM
RE: Word text formatting - by Rahull - 01-04-2011, 07:45 PM
RE: Word text formatting - by Rahull - 01-05-2011, 04:13 PM
RE: Word text formatting - by Saket - 01-05-2011, 05:11 PM
RE: Word text formatting - by Rahull - 01-05-2011, 05:56 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Check the word and get no. of times that word in the webpage Sandeep.san229 0 1,185 10-31-2018, 06:42 PM
Last Post: Sandeep.san229
  pageDown in word.application wannel 0 1,674 11-25-2016, 10:06 PM
Last Post: wannel
  Automating Word Docs bart02 0 2,688 07-18-2014, 03:25 AM
Last Post: bart02
  Highlight the Found text in Word/notepad Sivakumar2186@gmail.com 2 3,503 10-21-2013, 06:31 PM
Last Post: BadrinarayananR
  Read text from text file and save it into a variable in qtp arpan 3 12,147 06-19-2013, 08:34 PM
Last Post: arpan

Forum Jump:


Users browsing this thread: 1 Guest(s)