Ini contohnya
Public Excel_App As Object
Function Excel_Created(Excel_File_Name As String)
' Create the Excel application.
Set Excel_App = CreateObject("Excel.Application")
' Create a new spreadsheet.
Excel_App.Workbooks.Add
' Save the excel file
Excel_App.ActiveWorkbook.SaveAs
FileName:=Excel_File_Name
End Function
--- Pak Rur <[EMAIL PROTECTED]> wrote:
> Dulu saya dapat dari vbhelper, catatan saya sbb:
>
> dibuat 1 class module (ExcelFile.cls)
> dibuat 1 form (form1)
> dalam form1 dibuat 1 commandbutton
> untuk ngetest jalankan pembuatan file excel)
>
> ' === MULAI=====
> '=====coding untuk class module (ExcelFile.cls)=====
> '---Beginning Of File record
> Private Type BOF
> opcode1 As Byte
> opcode2 As Byte
> length1 As Byte
> length2 As Byte
> version1 As Byte
> version2 As Byte
> ftype1 As Byte
> ftype2 As Byte
> End Type
>
> '---End Of File record
> Private Type EOF
> opcode1 As Byte
> opcode2 As Byte
> length1 As Byte
> length2 As Byte
> End Type
>
> '---Integer record
> Private Type tInteger
> opcode1 As Byte
> opcode2 As Byte
> length1 As Byte
> length2 As Byte
> row1 As Byte
> row2 As Byte
> col1 As Byte
> col2 As Byte
> rgbattr1 As Byte
> rgbAttr2 As Byte
> rgbAttr3 As Byte
> w1 As Byte
> w2 As Byte
> End Type
>
> '---Label (Text) record
> Private Type tLabel
> opcode1 As Byte
> opcode2 As Byte
> length1 As Byte
> length2 As Byte
> row1 As Byte
> row2 As Byte
> col1 As Byte
> col2 As Byte
> rgbattr1 As Byte
> rgbAttr2 As Byte
> rgbAttr3 As Byte
> length As Byte
> End Type
>
> Dim fhFile As Integer
> Dim bof1 As BOF
> Dim eof1 As EOF
> Dim l1 As tLabel
> Dim i1 As tInteger
>
> Public Sub OpenFile(ByVal FileName As String)
> fhFile = FreeFile
> Open FileName For Binary As #fhFile
> Put #fhFile, , bof1
> End Sub
>
> Public Sub CloseFile()
> Put #fhFile, , eof1
> Close #fhFile
> End Sub
>
>
> Private Sub Class_Initialize()
> '---Set up default values for records
> '---These should be the values that are the same for
> every record
>
> With bof1
> .opcode1 = 9
> .opcode2 = 0
> .length1 = 4
> .length2 = 0
> .version1 = 2
> .version2 = 0
> .ftype1 = 10
> .ftype2 = 0
> End With
>
> With eof1
> .opcode1 = 10
> End With
>
> With l1
> .opcode1 = 4
> .opcode2 = 0
> .length1 = 10
> .length2 = 0
> .row2 = 0
> .col2 = 0
> .rgbattr1 = 0
> .rgbattr1 = 0
> .rgbattr1 = 0
> .length = 2
> End With
>
> With i1
> .opcode1 = 2
> .opcode2 = 0
> .length1 = 9
> .length2 = 0
> .row1 = 0
> .row2 = 0
> .col1 = 0
> .col2 = 0
> .rgbattr1 = 0
> .rgbAttr2 = 0
> .rgbAttr3 = 0
> .w1 = 0
> .w2 = 0
> End With
>
> End Sub
>
> Function EWriteString(r As Byte, c As Byte, t As
> String)
> Dim b As Byte
> Dim l As Byte
> stringtowrite = t
> l = Len(stringtowrite)
>
> '---Length of the text portion of the record
> l1.length = l
>
> '---Total length of the record
> l1.length1 = 8 + l
>
> '---BIFF counts from zero
> l1.row1 = r - 1
> l1.col1 = c - 1
>
> '---Put record header
> Put #fhFile, , l1
> '---Then the actual string data
> For a = 1 To l
> b = Asc(Mid$(stringtowrite, a, 1))
> Put #fhFile, , b
> Next
>
> End Function
>
> Function EWriteInteger(r As Byte, c As Byte, i As
> Long)
>
> With i1
> .row1 = r - 1
> .col1 = c - 1
> .w1 = i - (Int(i / 256) * 256)
> .w2 = Int(i / 256)
> End With
>
> Put #fhFile, , i1
>
> End Function
>
>
> '=====coding untuk form (frm1.frm)=====
>
> Private Sub Command1_Click()
> Dim colu As Byte
> Dim rw As Byte
>
> 'membuat excel class baru = ef1
> Dim ef1 As New ExcelFile
>
> With ef1
> 'path-nya akan berada di folder
> 'dimana program ini di run. (misal:
> D:\myVBcodes\TestVB.xls
> .OpenFile "TestVB.xls"
> ' tulis data integer @ col 1, row 1
> .EWriteInteger 1, 1, 100
> ' tulis data string @ col 2, row 1
> .EWriteString 1, 2, "Test tulis string"
> ' tulis string lain @ col 3, row 1
> .EWriteString 1, 3, "Pak Rur"
> .CloseFile
> End With
>
> End Sub
> '=============== selesai ========
>
> --- Arif LukmanHakim <[EMAIL PROTECTED]> wrote:
> >
>
=== message truncated ===
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Untuk keluar dari millis ini, kirim email kosong ke:
[EMAIL PROTECTED]
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/Programmer-VB/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/