I'd solve my problem now!! hope this may help other..
1. I change type of variable oExcelApp from Excel.Application to Object and same for workbook & worksheet
2. You must be sure ,u have Excel'd installed on ur machine.
VB Code:
Dim oExcelapp As Object, oExcelwk As Object Private Sub Form_Load() On Error Resume Next Set oExcelApp = GetObject(, "Excel.Application") If Err.Number <> 0 Then Set oExcelApp = CreateObject("Excel.Application") DoEvents End If Err.Clear Set oExcelwk = oExcelapp.Workbooks.Open("[yourexcelfile.xls]") oExcelwk.Activate oExcelapp.Visible = True MsgBox "OK" oExcelwk.Close False oExcelapp.Quit End Sub
use above code to test opening file excel





Reply With Quote