The VB6.0 is inserted into the excel table why runtime always prompts the user d

Option Explicit
Dim xlApp As Excel.Application 'Define a EXCEL class
Dim xlBook As Excel.Workbook 'The book class definition
Dim xlsheet As Excel.Worksheet 'The definition of work table
Private Sub Command1_Click()
Dim i As Integer, j As Integer
Set xlApp = CreateObject("Excel.Application") 'Create a EXCEL application
xlApp.Visible = False 'Set the EXCEL invisible
Set xlBook = xlApp.Workbooks.Open(App.Path & "\data.xls") 'Open the EXCEL Workbook
Set xlsheet = xlBook.Worksheets(1) 'Open the EXCEL worksheet
'xlsheet.Activate 'Activation of work table
Dim litem
For i = 2 To 7 'Line / record number

Set litem = ListView1.ListItems.Add()
litem.Text = xlsheet.Cells(i, 1)
litem.SubItems(1) = xlsheet.Cells(i, 2)
litem.SubItems(2) = xlsheet.Cells(i, 3)
litem.SubItems(3) = xlsheet.Cells(i, 4)
'MsgBox xlsheet.Cells(i, j)

xlBook.Close (True) 'Close the EXCEL Workbook
xlApp.Quit 'Close EXCEL
Set xlApp = Nothing 'The release of the EXCEL object

End Sub

Started by Sherry at December 24, 2016 - 3:45 PM

Add EXCEL reference no?

Posted by Craig at December 28, 2016 - 4:42 PM

In the VB interface, select menu "Engineering" - "reference", in the pop-up dialog box, select the Microsoft Excel 11 Object Library determination. (your machine version number may vary)

Posted by Jimmy at December 31, 2016 - 5:35 PM