otomatiasasi MS.Excel Database dan MS.Word Sertifikat dengan VBnet

DesignExcel

DesignWord

DesignVbnet

inputVbnet

outputExcel

outputWord

Dan Berikut Codingnya:

‘Import Excel

Imports Excel = Microsoft.Office.Interop.Excel
‘import Word
Imports Word = Microsoft.Office.Interop.Word

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

‘Block Code Ini Digunakan untuk melakukan pada Dokumen MS. Excel
Dim AppExcel As New Excel.Application
Dim wrkExcel As Excel.Workbook

AppExcel.Visible = True
wrkExcel = AppExcel.Workbooks.Open(“C:\dataExcel.xlsx”)

AppExcel.Range(“C6”).Insert()
AppExcel.Range(“D6”).Insert()
AppExcel.Range(“E6”).Insert()
AppExcel.Range(“F6”).Insert()
AppExcel.Range(“G6”).Insert()

AppExcel.Range(“C6”).Value = textnama.Text
AppExcel.Range(“D6”).Value = textkelamin.Text
AppExcel.Range(“E6”).Value = textnamapohon.Text
AppExcel.Range(“F6”).Value = textnilai.Text
AppExcel.Range(“G6”).Value = textlama.Text

wrkExcel.Save()

‘Block Ini digunakan untuk melakukan automation pada Dokumen MS.Word

Dim AppWord As New Word.Application
Dim docWord As New Word.Document

AppWord.Visible = True
docWord = AppWord.Documents.Open(“C:\dataSertifikat.docx”)

docWord.Bookmarks(“namapeserta”).Select()
AppWord.Selection.TypeText(textnama.Text)
docWord.Bookmarks(“kelamin”).Select()
AppWord.Selection.TypeText(textkelamin.Text)

docWord.Bookmarks(“namapohon”).Select()
AppWord.Selection.TypeText(textnamapohon.Text)

docWord.Bookmarks(“nilai”).Select()
AppWord.Selection.TypeText(textnilai.Text)

docWord.Bookmarks(“lama”).Select()
AppWord.Selection.TypeText(textlama.Text)

docWord.Save()

End Sub
End Class

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout /  Ubah )

Foto Google

You are commenting using your Google account. Logout /  Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )

Connecting to %s