pertama-tama siapkan word dan excel dengan desain begini
abis itu di wordnya di isian tambahkan bookmark masing
untuk pemrogramannya buka visual studiom,new project
awal2 buka project>>add reference>>COM>>tambahin library word dan excel
desain form kayak gini
di button word dan excel masing2 dimasukin koding ini
button word
Imports word = Microsoft.Office.Interop.Word
Imports eksel = Microsoft.Office.Interop.ExcelPublic Class Form1
Private Sub Label6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label6.TextChanged
Label6.Text = Date.Now
End Sub
Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox4.TextChanged
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myWordApp As New word.Application
Dim myWordDoc As New word.Document
If (ComboBox1.Text = 1) Then
TextBox4.Text = TextBox3.Text * 500000
End If
If (ComboBox1.Text = 2) Then
TextBox4.Text = TextBox3.Text * 650000
End If
If (ComboBox1.Text = 3) Then
TextBox4.Text = TextBox3.Text * 1000000
End If
myWordDoc = myWordApp.Documents.Open("E:\Travel.docx")
myWordDoc.Bookmarks("nama").Select()
myWordApp.Selection.Font.Size = 16
myWordApp.Selection.TypeText(TextBox1.Text)
myWordDoc.Bookmarks("alamat").Select()
myWordApp.Selection.Font.Size = 16
myWordApp.Selection.TypeText(TextBox2.Text)
myWordDoc.Bookmarks("nomur").Select()
myWordApp.Selection.Font.Size = 16
myWordApp.Selection.TypeText(TextBox3.Text)
myWordDoc.Bookmarks("paket").Select()
myWordApp.Selection.Font.Size = 16
myWordApp.Selection.TypeText(ComboBox1.Text)
myWordDoc.Bookmarks("qty").Select()
myWordApp.Selection.Font.Size = 16
myWordApp.Selection.TypeText(TextBox5.Text)
myWordDoc.Bookmarks("harga").Select()
myWordApp.Selection.Font.Size = 16
myWordApp.Selection.TypeText(TextBox4.Text)
myWordDoc.Bookmarks("tgl").Select()
myWordApp.Selection.Font.Size = 16
myWordApp.Selection.TypeText(Label6.Text)
myWordDoc.SaveAs("E:\printtravel.docx")
myWordApp.Visible = True
myWordApp.Quit()
End Sub
button excel
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.ClickDim myExcelApp As New eksel.Application
Dim myExcelBook As eksel.Workbook
myExcelApp.Visible = True
myExcelBook = myExcelApp.Workbooks.Open("E:\faktur.xlsx")
myExcelApp.Range("F3").Font.Size = 11
myExcelApp.Range("F3").Font.Bold = 1
myExcelApp.Range("F3").Value = TextBox1.Text
myExcelApp.Range("F4").Font.Size = 11
myExcelApp.Range("F4").Font.Bold = 1
myExcelApp.Range("F4").Value = TextBox2.Text
myExcelApp.Range("A9").Font.Size = 11
myExcelApp.Range("A9").Value = TextBox3.Text
myExcelApp.Range("B9").Font.Size = 11
myExcelApp.Range("B9").Value = ComboBox1.Text
myExcelApp.Range("D9").Font.Size = 11
myExcelApp.Range("D9").Value = TextBox5.Text
myExcelApp.Range("E9").Font.Size = 11
myExcelApp.Range("E9").Value = TextBox4.Text
myExcelApp.Range("C7").Font.Size = 11
myExcelApp.Range("C7").Value = Label6.Text
myExcelBook.SaveAs("E:\fakturprint.xlsx")
myExcelApp.Quit()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.Close()
End Sub
End Class