Home > Software engineering >  Why vb6.0 by use of the command button to insert the excel table runtime always prompt the user defi
Why vb6.0 by use of the command button to insert the excel table runtime always prompt the user defi

Time:10-17

 Option Explicit 
Dim xlApp As Excel. Class defined Excel Application '
Dim xlBook As Excel. The Workbook 'class definition artifacts book
Dim xlsheet As Excel. The Worksheet 'definition Worksheet class
Private Sub Command1_Click ()
Dim I As an Integer, j As Integer
The Set xlApp=CreateObject (" Excel. Application ") 'create Excel Application class
XlApp. Visible=False 'set of EXCEL is not currently Visible
The Set xlBook=xlApp. Workbooks. Open (App) Path & amp; "\ data. XLS") 'open the EXCEL workbook
Set xlsheet=xlBook. Worksheets (1) the 'open the EXCEL Worksheets
'xlsheet. Activate to Activate worksheet
Dim litem
For I=2 To 7 'row/record number

Set litem=ListView1. ListItems. The 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)

Next
XlBook. Close (True) 'Close EXCEL workbook
XlApp. Quit 'close EXCEL
The Set xlApp release EXCEL object
=Nothing '
End Sub

CodePudding user response:

Don't add EXCEL reference?

CodePudding user response:

Under the VB interface, choose the menu "engineering" - "reference", check the Microsoft Excel in the pop-up dialog box 11.0 Object after the Library, (the version number may be different on your machine)

CodePudding user response:

Look not to understand ah HAHAH
  • Related