itu bisa dilakukkan bahwa excel itu dianggap Database..
jadi pertama koneksi ke excelnya.. spt dibawah berikut:


Public cn As ADODB.Connection
Public Cn2 As ADODB.Connection
Public Strsql As String
Public Rs As ADODB.Recordset
Public Sub AutoOpen()
'On Error GoTo Errh:
Dim Fld As ADODB.Field
Set cn = New ADODB.Connection
Set Cn2 = New ADODB.Connection
Dim DirF As String
Dim DirM As String

with cn
   .Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
              "Data Source=" & App.Path & "\LocalSales.xls;" & _
             "Extended Properties=""Excel 8.0;HDR=NO;"""
End With



    Set Rs = New ADODB.Recordset
  With Rs
     .CursorLocation = adUseClient
    .Open "Select * from [DATA$]", cn, adOpenStatic, adLockOptimistic
     .AddNew
    .Fields("nama").Value = Sheets("sheet1").Cells(1, 1).Value
    .Fields("alamat").Value = Sheets("sheet1").Cells(2, 1).Value
     .Update
     .Close
  End With





jadi koneks ke excel..terlebih dahulu,baru melakukkan filterisasi..

untuk databasenya harus mempunyai fields yang baris pertama di file
excelnya..













  'Set cn = Nothing
'Errh:
'   MsgBox Err.Number

End Sub







On 7/23/07, rukawa kaede <[EMAIL PROTECTED]> wrote:

   setahuku nama Field di Database gak sama dengan nama di Property VB nya
coba cek ...

----- Pesan Asli ----
Dari: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
Kepada: [email protected]
Terkirim: Jumat, 20 Juli, 2007 8:21:49
Topik: Re: [Programmer-VB] baca file excel lalu ditampilkan di flexgrid

 Coba pelajari coding di bawah :


Dim xl As New Excel.Application

Dim xlw As Excel.Workbook



'Open Excel File

Set xlw = xl.Workbooks. Open(txtPath. Text)



'Choose Sheet1

'xlw.Sheets( "Sheet1") .Select



'Get value from cells

For i = 2 To 500

    If IsEmpty(xlw. Application. Cells(i, 1).Value) Then Exit For

    lcKode = xlw.Application. Cells(i, 1).Value

    lcNama = xlw.Application. Cells(i, 2).Value

    lcAlamat = xlw.Application. Cells(i, 3).Value



    strsql = "insert DataCust (kode,nama,alamat) " & _

        "values('" & lcKode & "','" & lcNama & "','" & lcAlamat & "')"

    cnmyconnect. Execute strsql

Next i



'Close Excel File

xlw.Close False

Set xlw = Nothing

Set xl = Nothing



Saya tidak coba dulu, soalnya kebetulan komp yg ini nggak ada VB nya. Coba
aja dioprek2.

Kalau mau ditampilkan dulu ke DataGrid misalnya, sepertinya open
connection nya udah pakai Excel. Coba aja cari2 VB open excel as database di
google. Tapi syaratnya, file excelnya harus ada header di baris 1, datanya
mulai baris ke-2 (kalo ga salah loh..)



Semoga membantu,

Liung's

www.apktntajd. com <http://www.apktntajd.com/> (Ape Kate Ente Aje Deh!)



----- Original Message -----
*From:* restu_suci <[EMAIL PROTECTED]>
*To:* Programmer-VB@ yahoogroups. com <[email protected]>
*Sent:* Thursday, July 12, 2007 2:11 PM
*Subject:* [Programmer- VB] baca file excel lalu ditampilkan di flexgrid



Slm kenal..
Saya sudah mencoba file yang ada di forum ini judulnya ambilDataExcel
saya coba modifikasi filenya tapi malah muncul error seperti ini :
"ADO could not find the object in the collection corresponding to the
name or ordinal referrence requested by the application"
Maksudnya apa?
Saya bingung soalnya saya baru pemula dalam programming vb..
terima kasih sebelumnya..




------------------------------
Bergabunglah dengan orang-orang yang berwawasan, di bidang Anda di Yahoo!
Answers<http://sg.rd.yahoo.com/mail/id/footer/def/*http://id.answers.yahoo.com/>



Kirim email ke