Dim xlsApp As Excel.Application
Dim wrdApp As Word.Application
Private Sub Command1_Click()
CommonDialog1.InitDir = App.Path
CommonDialog1.DialogTitle = "电子表格"
CommonDialog1.Filter = "电子表格|*.xls"
CommonDialog1.ShowOpen
Label1.Caption = CommonDialog1.FileName
Dim wjm As String
wjm = CommonDialog1.FileName
Set xlApp = CreateObject("Excel.Application") '创建EXCEL对象
Set xlBook = xlApp.Workbooks.Open(wjm) '打开已经存在的EXCEL工件簿文件
xlApp.Visible = False '设置EXCEL对象可见(或不可见)
Set xlSheet = xlBook.Worksheets("Sheet1") '设置活动工作表
xlSheet.Activate
Dim i As Integer
For i = 1 To xlSheet.UsedRange.Rows.Count
List1.AddItem (i)
For j = 1 To 5
List1.AddItem (xlSheet.Cells(i, j))
Next
Next
'List1.AddItem (xlSheet.UsedRange.Rows)
'xlSheet.Cells(Row, col) = 值 '给单元格(row,col)赋值
'xlSheet.PrintOut '打印工作表
'xlBook.Close (True) '关闭工作簿
xlApp.Quit '结束EXCEL对象
'Set xlApp = Nothing '释放xlApp对象
'xlBook.RunAutoMacros (xlAutoOpen) '运行EXCEL启动宏
'xlBook.RunAutoMacros (xlAutoClose) '运行EXCEL关闭宏
End Sub