Is it possible to create a plugin or addin for MS Word that allows a section of text to be selected and then a custom "Highlighting" function to be applied to it.
I want this to all be within MS Word not a cut and past from another application.
If possible, any suggestions on where I could find some direction on how to do this ( using C# )
VBA - Visual Basic for Applications is your tool for this type of work in Office. It stays self-contained as well.
Shows manipulating text.
http://computerprogramming.suite101.com/article.cfm/introduction_to_vba_for_ms_word
VBA Tutorial:
http://jy.fridaynight.co.il/pages/dev/WordVBA.php
Bunch of examples.
http://www.thezcorp.com/VBACodeSamples.aspx
A Cornucopia:
http://www.java2s.com/Code/VBA-Excel-Access-Word/CatalogVBA-Excel-Access-Word.htm
Now that you know what to search for as well, hopefully you are on your way.
EDIT: Found this code example:
Sub ChangeColor
Options.DefaultHighlightColorIndex = wdBrightGreen
Selection.Find.ClearFormatting
Selection.Find.Highlight = True
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Highlight = True
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Font.Color = wdColorBrightGreen
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Font.Color = wdColorRed
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
HTH
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With