简体   繁体   English

使用Microsoft互操作在Word C#中填充字母

[英]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.

相关问题 使用c#和Microsoft Word Interop填充Word中的字段 - Filling fields in Word using c# and Microsoft Word Interop 如何使用Microsoft Word Interop书签C#选中一个框 - How to check a box using Microsoft Word Interop Bookmarks C# 使用参考C#添加Microsoft.Office.InterOp.Word - Add Microsoft.Office.InterOp.Word using reference C# C#Microsoft.Office.Interop.Word - C# Microsoft.Office.Interop.Word C#Microsoft Word自动化Microsoft.Office.Interop.Word - C# Microsoft Word automation Microsoft.Office.Interop.Word 使用C#中的Microsoft.Office.Interop.Word在MS Word中查找具有指定字体的文本 - Finding Text With specified font in MS word using Microsoft.Office.Interop.Word in c# 如何使用Microsoft.Office.Interop.Word在C#中从Word文件中查找突出显示的文本? - How to find highlighted text from Word file in C# using Microsoft.Office.Interop.Word? 如何在C#中使用Microsoft.Office.Interop.Word从Word文件(.Docx)中按页获取文本 - How to get text by page from word file (.Docx) using Microsoft.Office.Interop.Word in C# 如何使用microsoft.office.interop.word c#从word文件中获取段落和形状 - How to get paragraphs and shapes from word file using microsoft.office.interop.word c# 如何使用Microsoft.Office.Interop.Word C#在Word文档中插入/获取封面 - How to insert/fetch a cover page in word document using Microsoft.Office.Interop.Word C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM