Skip to main content

Posts

Showing posts from April, 2017

Extracting the yellow highlighted text from Microsoft Word file using VBA

Function CS_ExtractHighlightedWords ( ) As Boolean Dim CS_objRange As Range Dim CS_NewDoc_Obj As Document Dim CS_CollectionObj As New Collection Set CS_objRange = Application . ActiveDocument . Range With CS_objRange . Find . Highlight = True Do While . Execute If CS_objRange . HighlightColorIndex = wdYellow Then On Error Resume Next CS_CollectionObj . Add CS_objRange . Text , CStr ( CS_objRange . Text ) 'Here we are avoiding the duplicate values to be stored in the collection using the key 'If any of the extracted word is being stored as duplicate key then program will through 457 error. On Error GoTo 0 End If Loop End With On Error Resume Next Set CS_NewDoc_Obj = Documents . Open ( FileName : = "F:\log.docx" , AddToRecentFiles : = ...