Type In RichTextBox and Save as MS WORD file
Coding:
Imports Microsoft.Office.Interop.Word
Public Class RTB2MSWord
Dim Word As Microsoft.Office.Interop.Word.Application
Private Sub RTB2MSWord_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Word = New Microsoft.Office.Interop.Word.Application
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim app As New Microsoft.Office.Interop.Word.Application()
'app.Visible = True
Dim tempOutputPath As Object = "E:\Zoo Management\Zoo Management\Documents\" & TextBox1.Text & ".rtf"
RichTextBox1.SaveFile(DirectCast(tempOutputPath, String))
Dim typeMissing As Object = Type.Missing
Dim trueIndicator As Object = True
app.Documents.Open(tempOutputPath, typeMissing, typeMissing, typeMissing, typeMissing, typeMissing, typeMissing, typeMissing, typeMissing, typeMissing, typeMissing, trueIndicator, typeMissing, typeMissing, typeMissing, typeMissing)
app.Quit()
MsgBox("Export Complete")
End Sub
End Class
Coding:
Imports Microsoft.Office.Interop.Word
Public Class RTB2MSWord
Dim Word As Microsoft.Office.Interop.Word.Application
Private Sub RTB2MSWord_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Word = New Microsoft.Office.Interop.Word.Application
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim app As New Microsoft.Office.Interop.Word.Application()
'app.Visible = True
Dim tempOutputPath As Object = "E:\Zoo Management\Zoo Management\Documents\" & TextBox1.Text & ".rtf"
RichTextBox1.SaveFile(DirectCast(tempOutputPath, String))
Dim typeMissing As Object = Type.Missing
Dim trueIndicator As Object = True
app.Documents.Open(tempOutputPath, typeMissing, typeMissing, typeMissing, typeMissing, typeMissing, typeMissing, typeMissing, typeMissing, typeMissing, typeMissing, trueIndicator, typeMissing, typeMissing, typeMissing, typeMissing)
app.Quit()
MsgBox("Export Complete")
End Sub
End Class
No comments:
Post a Comment