[英]using Microsoft interop to fill a letter in Word C#
I am Trying out a Program to Fill a Letter in Microsoft Word using Interop in C#. 我正在尝试使用C#中的Interop在Microsoft Word中填充字母的程序。 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
这个问题有解决方案吗
When modifying a Word document with interop, I use the "replace bookmark" functionality. 通过互操作修改Word文档时,我使用“替换书签”功能。 You define bookmarks in your model .doc then replace them with text at runtim with I wrote this function
您在模型.doc中定义书签 ,然后用我编写的此函数在runtim处将其替换为文本
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.