0
votes

I am Trying out a Program to Fill a Letter in Microsoft Word using Interop in C#. I have hard coded all the Text that is to be filled in word in my program.

but While running my program I could see that I am not able to use the normal copy and paste option in my computer. While doing so it pastes the text that is copied by my program in clipboard. Is there a solution for this Problem

1

1 Answers

0
votes

When modifying a Word document with interop, I use the "replace bookmark" functionality. You define bookmarks in your model .doc then replace them with text at runtim with I wrote this function

Public Shared Sub ReplaceBookmarkText(ByVal doc As Microsoft.Office.Interop.Word.Document, ByVal bookmarkName As String, ByVal text As String)
    If (doc.Bookmarks.Exists(bookmarkName)) Then
        Dim range As Microsoft.Office.Interop.Word.Range = doc.Bookmarks(bookmarkName).Range
        range.Text = text
        doc.Bookmarks.Add(bookmarkName, range)
    End If
End Sub