如何在C#中将文本从RTF传输到Word文档
我需要将文本从 richTextbox 传输到 Word 文档,并且还需要在单击按钮时以纯文本形式传输。我需要这方面的帮助。
我有一个 vb 代码,但需要 csharp。
Dim wrdApp As Word.Application
Private Sub Form_Load()
Set wrdApp = New Word.Application
End Sub
Private Sub Command2_Click()
Clipboard.SetText RichTextBox1.TextRTF, vbCFRTF
With wrdApp
.Documents.Add
.Selection.Paste
.ActiveDocument.SaveAs App.Path & "RTFDOC2.doc", _
wdFormatDocument
.Visible = True
.Activate
End With
End Sub
hI I need to transfer text from richTextbox to word document and also in plain text on button_click. I need assistance on this please.
I got a vb code but need in csharp.
Dim wrdApp As Word.Application
Private Sub Form_Load()
Set wrdApp = New Word.Application
End Sub
Private Sub Command2_Click()
Clipboard.SetText RichTextBox1.TextRTF, vbCFRTF
With wrdApp
.Documents.Add
.Selection.Paste
.ActiveDocument.SaveAs App.Path & "RTFDOC2.doc", _
wdFormatDocument
.Visible = True
.Activate
End With
End Sub
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我根据 此网站< /a>:
I found and put the following together based off this site:
您可以使用 msword 的 activeX-IF 调用此 VBA 代码。
You can call this VBA code using the activeX-IF of msword.