1个回答
展开全部
'引用Microsoft Excel 12.0 Object Library
'Excel文件放于D盘目录下,名称为:my.xls
Private Sub Command1_Click()
Dim A(101) As String
Dim i As Integer
Dim xlsApp As Excel.Application
Dim xlsWorkbook As Excel.Workbook
Dim xlssheet As Excel.Worksheet
Set xlsApp = CreateObject("Excel.Application")
Set xlsWorkbook = xlsApp.Workbooks.Open("D:\my.xls")
xlsApp.Visible = True
xlsApp.Range("A1").Select
'读取值
Text1.text = xlsApp.ActiveCell.Offset(0, 1).Value
Set xlssheet = Nothing
Set xlsWorkbook = Nothing
Set xlsApp = Nothing
End Sub
'Excel文件放于D盘目录下,名称为:my.xls
Private Sub Command1_Click()
Dim A(101) As String
Dim i As Integer
Dim xlsApp As Excel.Application
Dim xlsWorkbook As Excel.Workbook
Dim xlssheet As Excel.Worksheet
Set xlsApp = CreateObject("Excel.Application")
Set xlsWorkbook = xlsApp.Workbooks.Open("D:\my.xls")
xlsApp.Visible = True
xlsApp.Range("A1").Select
'读取值
Text1.text = xlsApp.ActiveCell.Offset(0, 1).Value
Set xlssheet = Nothing
Set xlsWorkbook = Nothing
Set xlsApp = Nothing
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询