How to generate replacement text from found text (VB and Word Office-Interop) RRS feed

  • Question

  •    I need to add correct stress accents to every word in a MS Word document.  I have a script called "DoAccentuate" which determines the correct accentuation for any word that is input.  However, I don't know how to capture the currently selected found word, process it with my DoAccentuate script, and replace that same word with the result (without effecting the formatting of the text).  This is what I tried.

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim document As Word.Document
            document = Globals.ThisAddIn.Application.ActiveDocument
            Dim FindObject As Word.Find = document.Application.Selection.Find
            With FindObject
                .Text = "<*>"
                .MatchWildcards = True
                .Replacement.Text = DoAccentuate(document.Application.Selection.Text)
            End With
        End Sub

    • Moved by Youen Zen Monday, April 8, 2013 8:08 AM From Visual Basic
    Saturday, April 6, 2013 7:38 AM

All replies