1. Tambahkan satu buah module dan simpan dengan nama ModExport
2. Ketikkan script berikut pada ModExport:
artikel terkait : http://komtipstrik.blogspot.co.id/2016/02/memulai-pemrograman-di-visual-basic-60.html
1 | Dim objXL As New Excel.Application Dim wbXL As New Excel.Workbook Dim wsXL As New Excel.Worksheet Dim intRow As Integer ' counter Dim intCol As Integer ' counter Public Sub SimpanKeExcelDinamis(TheFlexgrid As VSFlexGrid, _ TheRows As Integer, TheCols As Integer, _ Optional GridStyle As Integer = 1, Optional WorkSheetName _ As String) If Not IsObject(objXL) Then MsgBox "You need Microsoft Excel to use this function", _ vbExclamation, "Print to Excel" Exit Sub End If On Error Resume Next objXL.Visible = True Set wbXL = objXL.Workbooks.Add Set wsXL = objXL.ActiveSheet For intRow = 1 To TheRows For intCol = 1 To TheCols With TheFlexgrid wsXL.Cells(intRow, intCol).Value = "'" & .TextMatrix(intRow - 1, intCol - 1) & " " End With Next Next For intCol = 1 To TheCols wsXL.Columns(intCol).AutoFit Next With wsXL If Not WorkSheetName = "" Then .Name = WorkSheetName .SaveAs App.Path & "\Excel File\" & WorkSheetName End If End With End Sub |
Cat: |
|
artikel terkait : http://komtipstrik.blogspot.co.id/2016/02/pembuatan-module-pada-pemrograman.html
Tidak ada komentar:
Posting Komentar