Your not using the book or sheet objects and running everything off ogf the application object which is incorrect.
VB Code:
Set objExcel = CreateObject("excel.application") 'Starts the Excel Session Set objBook = objExcel.Workbooks.Add 'Add a Workbook Set objSheet = objBook.Sheets.Item(2) 'Select second Sheet objExcel.Visible = True objSheet.Cells(1, 1).Value = "Kod Kategori BA" objSheet.Cells(1, 2).Value = "No.BA" With objSheet .Cells(n, 1).Value = ((Trim(DataHRMIS.Recordset.Fields("BACatCd").Value))) .Cells(n, 2).Value = ((Trim(DataHRMIS.Recordset.Fields("BANo").Value))) End With Set objSheet = Nothing objBook.Close True Set objBook = Nothing objExcel.Quit Set objExcel = Nothing





Reply With Quote