Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports Word = Microsoft.Office.Interop.Word
- Public Class Form6
- Dim objWord As New Word.Application
- Dim objDoc As New Word.Document
- Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
- objDoc = objWord.Documents.Open("D:\Proyek VB NET Latihan\Latihan22\Latihan22\Latihan22\Template1.dotm")
- With objWord
- 'Make Word Application Visible
- .Visible = True
- 'Sets Alignment to Left
- .Selection.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft
- 'Set Font
- .ActiveWindow.Selection.Font.Name = "Arial"
- 'Set Font Size
- .ActiveWindow.Selection.Font.Size = 8
- 'Focus on Footer ( Use wdSeekCurrentPageHeader to focus on header )
- .ActiveWindow.ActivePane.View.SeekView = Word.WdSeekView.wdSeekCurrentPageFooter
- 'Set font
- .ActiveWindow.Selection.TypeText("PDAM Kota Balikpapan")
- 'Resets focus back to main document
- .ActiveWindow.ActivePane.View.SeekView = Word.WdSeekView.wdSeekMainDocument
- 'Perintah untuk Mengirim file ke printer
- ' .PrintOut()
- End With
- Dim strOpening As String = "Dear " & TextBox1.Text & "," & vbCrLf & vbCrLf
- Dim strLetter As String = "Letter Body Here" & vbCrLf & vbCrLf
- Dim strClosing As String = "Yours Sincerely, " & vbCrLf & vbCrLf & TextBox2.Text
- objWord.ActiveWindow.Selection.TypeText(strOpening & strLetter & strClosing)
- End Sub
- Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
- 'Find out how many files are saved in the Save folder
- Dim int As Integer
- int = My.Computer.FileSystem.GetFiles("D:\fileExcel\").Count + 1
- 'Save As command
- objDoc.SaveAs2("D:\fileExcel\" & int & ".doc")
- End Sub
- Private Sub Form6_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
- objWord.Quit()
- Try
- objWord.Quit()
- Catch ex As Exception
- End Try
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement