Pada button1 codingnya
'Membuat sebuah variabel baru untuk app, doc dan hasil
Dim
myWordApp As New
word.Application
Dim
myWordDoc As New
word.Document
If
ComboBox1.Text = "1" Then
TextBox4.Text = 500000
ElseIf
ComboBox1.Text = "2" Then
TextBox4.Text = 1000000
End If
TextBox5.Text = TextBox3.Text *
TextBox4.Text
'Membuka file
minggu3.docx
myWordDoc = myWordApp.Documents.Open("D:\Rian.doc")
myWordDoc.SaveAs("D:\Rian1.doc")
myWordDoc.Bookmarks("NamaPel").Select()
myWordApp.Selection.TypeText(TextBox1.Text)
myWordDoc.Bookmarks("NamaBar").Select()
myWordApp.Selection.TypeText(ComboBox1.Text)
myWordDoc.Bookmarks("Jumlah").Select()
myWordApp.Selection.TypeText(TextBox3.Text)
myWordDoc.Bookmarks("Harga").Select()
myWordApp.Selection.TypeText(TextBox4.Text)
myWordDoc.Bookmarks("Total").Select()
myWordApp.Selection.TypeText(TextBox5.Text)
myWordApp.Visible = True
myWordApp.Quit()
Pada button2 codingnya
seperti ini
Dim
myexcelApp As New
excel.Application
Dim
myexcelbook As excel.Workbook
If
ComboBox1.Text = "1" Then
TextBox4.Text = 500000
ElseIf
ComboBox1.Text = "2" Then
TextBox4.Text = 1000000
End If
TextBox5.Text = TextBox3.Text *
TextBox4.Text
myexcelbook =
myexcelApp.Workbooks.Open("D:\Rian.xlsx")
myexcelApp.Range("A2").Value = TextBox1.Text
myexcelApp.Range("B2").Value = ComboBox1.Text
myexcelApp.Range("C2").Value = TextBox3.Text
myexcelApp.Range("D2").Value = TextBox4.Text
myexcelApp.Range("E2").Value = TextBox5.Text
myexcelApp.Visible = True
myexcelbook.SaveAs("D:\Rian1.xlsx")
myexcelApp.Quit()