Untuk menghindari jenis error seperti ini, akibat dari otomasi office di
antara aplikasinya (word via access, excel via access, and vice versa,
etc), maka gunakan trik berikut:
- untuk memudahkan penyusunan program, gunakan teknik early binding,
yaitu teknik yang sekarang anda gunakan, memasang mati reference pada
obyek excel yang terpasang di komputer developer. Dengan demikian
intelisense masih jalan saat kita menulis kode sehingga meminimasi
kesalahan penulisan sintak.
- setelah aplikasi final akan di release, lepas reference dan gunakan
teknik late binding, yaitu mengarahkan reference dalam kode.
contoh late binding bisa dipelajari dari cuplikan coding saya berikut:
Dim objExcelApp As Object
Dim objWorkbook As Object
Dim objWorksheet As Object
Dim objRange As Object
Dim objField As ADODB.Field
Dim i As Integer
On Error GoTo errHandle
Set objExcelApp = CreateObject("Excel.Application")
' Run Excel and open a new workbook
Set objWorkbook = objExcelApp.Workbooks.Add
' Get a reference to the first worksheet
Set objWorksheet = objWorkbook.Sheets(1)
objWorksheet.Name = "Data"
' Get a range reference for the first row
Set objRange = objWorksheet.Range("A1")
objRange.Cells(1, 1) = mstr_Company
Set objRange = objWorksheet.Range("A2")
objRange.Cells(1, 1) = mstr_Title
Set objRange = objWorksheet.Range("A3")
objRange.Cells(1, 1) = mstr_ReportDate
Set objRange = objWorksheet.Range("A5")
' Loop through the fields and put the field name in the first row
i = 0
For Each objField In mrs_Data.Fields
i = i + 1
objRange.Cells(1, i) = objField.Name
Next
' Get a reference to the second row
Set objRange = objWorksheet.Range("A6")
' Copy recordset to the range starting from the second row
Call objRange.CopyFromRecordset(mrs_Data, mrs_Data.RecordCount,
mrs_Data.Fields.Count)
' Bold the first row
objWorksheet.Rows("1:5").Font.Bold = True
objWorksheet.Range("A5").Select
objWorksheet.PivotTableWizard
objWorkbook.ActiveSheet.Name = "Pivot"
objWorksheet.Select
' Expend the columns to show entire content
'objWorksheet.Cells.EntireColumn.AutoFit
' Show Excel Sheet to user
objWorksheet.Move objWorkbook.Sheets("Pivot")
objExcelApp.Visible = True
Set objExcelApp = Nothing
aksan kurdin
easy goin wrote:
Dear Master access,
Mohon bantuanya untuk case access 2007 Runtime (Client menggunakan
Office 2003), muncul pesan error "database or project contains a
missing or broken reference to the file ‘EXCEL.EXE’ version 1.6"
Jika diclient terinstall office 2007, aplikasi dapat dijalankan tanpa
masalah.
Mohon solusinya, berhubung versi msoffice yang terinstall diclient
masih bervariasi
salam,
deden
------------------------------------------------------------------------
Lebih bergaul dan terhubung dengan lebih baik.
<http://sg.rd.yahoo.com/id/messenger/trueswitch/mailtagline/*http://id.messenger.yahoo.com/invite/>
Tambah lebih banyak teman ke Yahoo! Messenger sekarang!