Hello,
PB 2017R3
I use the following code to import data from Excel to Datawindow.
*********************************************
OLEObject xlapp , xlsub
dw_barcode.Reset()
dw_barcode.SetTransObject(Sqlca)
ll_sheet = 1
ls_filename = Trim(sle_filename.Text)
ls_ext = Mid(ls_filename, LastPos(ls_filename, '.'))
TRY
xlApp = Create OLEObject
ll_ret = xlApp.ConnectToNewObject( "Excel.Sheet" )
If ll_ret < 0 then
MessageBox("Connect to Excel Failed !", String(ll_ret))
lb_proceed = False
Return
End If
xlApp.Application.Workbooks.Open(ls_filename)
xlsub = xlapp.Application.ActiveWorkbook.Worksheets[ll_sheet]
ll_col_count = 14 // Fixed extra columns is there for our purpose
ll_max_rows = Xlsub.UsedRange.Rows.Count
ll_max_columns = Xlsub.UsedRange.Columns.Count
ll_cnt = 2
SetPointer(HourGlass!)
If lb_proceed = True Then
htb_1.Visible = True
dw_barcode.SetReDraw(False)
For ll_cnt = 2 to ll_max_rows
htb_1.Position = ll_cnt
If IsNull(Mid(Trim(String(xlsub.cells[ll_cnt, 1].value)),1,20)) = False and Trim(Mid(Trim(String(xlsub.cells[ll_cnt, 1].value)),1,20)) <> '' Then
ll_row = dw_barcode.InsertRow(0)
dw_barcode.SetItem(ll_row, 'usercode', Mid(Trim(String(xlsub.cells[ll_cnt, 1].value)),1,20))
dw_barcode.SetItem(ll_row, 'itemname', Mid(Trim(String(xlsub.cells[ll_cnt, 2].value)),1,80))
dw_barcode.SetItem(ll_row, 'oldpartno', Mid(Trim(String(xlsub.cells[ll_cnt, 3].value)),1,20))
dw_barcode.SetItem(ll_row, 'largecategory', Mid(Trim(String(xlsub.cells[ll_cnt, 4].value)),1,10))
dw_barcode.SetItem(ll_row, 'largecategoryname', Mid(Trim(String(xlsub.cells[ll_cnt, 5].value)),1,50))
dw_barcode.SetItem(ll_row, 'colour', Mid(Trim(String(xlsub.cells[ll_cnt, 6].value)),1,20))
dw_barcode.SetItem(ll_row, 'moq', Mid(Trim(String(xlsub.cells[ll_cnt, 7].value)),1,10))
dw_barcode.SetItem(ll_row, 'mrp', Dec(Trim(String(xlsub.cells[ll_cnt, 8].value))))
dw_barcode.SetItem(ll_row, 'ndp', Dec(Trim(String(xlsub.cells[ll_cnt, 9].value))))
dw_barcode.SetItem(ll_row, 'hsn', Mid(Trim(String(xlsub.cells[ll_cnt, 10].value)),1,20))
dw_barcode.SetItem(ll_row, 'sgstrate', Dec(Trim(String(xlsub.cells[ll_cnt, 11].value))))
dw_barcode.SetItem(ll_row, 'cgstrate', Dec(Trim(String(xlsub.cells[ll_cnt, 12].value))))
dw_barcode.SetItem(ll_row, 'igstrate', Dec(Trim(String(xlsub.cells[ll_cnt, 13].value))))
dw_barcode.SetItem(ll_row, 'cessrate', Dec(Trim(String(xlsub.cells[ll_cnt, 14].value))))
dw_barcode.SetItem(ll_row, 'selection', '')
End If
Next
dw_barcode.SetReDraw(True)
Else
MessageBox('Elifa', 'Cannot Proceed')
Return
End If
SetPointer(Arrow!)
XlApp.Application.Workbooks.close()
CATCH ( runtimeerror lo_rte)
MessageBox('Elifa', "MS Excel api runtime error")
FINALLY
// Quit
IF (IsValid(xlapp)) THEN
xlapp.application.quit() // This is the line which closed the PB Application also
xlapp.DisconnectObject()
END IF
dw_barcode.SetReDraw(True)
Destroy xlsub
Destroy xlapp
END TRY
********************************************
The same code works find in PB 11.5. Only IN PB 2017R3 I get this issue.
Any workaround or solution to this issue ?
Happiness Always
BKR Sivaprakash
Glad to know your issue is answered, Sivaprakash! Please mark this issue as resolved? Thanks!