VB调用Excel单元格数据
我的意思是在VB的text1中如何显示Excel表“D\myducuments\book1.xls”中sheet1中D4单元格的内容,要解释每步的意思...
我的意思是在VB的text1中如何显示Excel表“D\my ducuments\book1.xls”中sheet1中D4单元格的内容,要解释每步的意思
展开
展开全部
Private Sub Command1_Click()
Dim ExApp As New Excel.Application
Dim Exb As Excel.Workbook
Dim Exsh As Excel.Worksheet
Dim R1 As Excel.Range
ExApp.Workbooks.Open "D\my ducuments\book1.xls"
Set Exb = ExApp.Workbooks(1)
Set Exsh = Exb.Worksheets("Sheet1")
Text1.Text = Exsh.Range("D4")
ExApp.Workbooks.Close
ExApp.Quit
Set ExApp = Nothing
End Sub
运行前要在菜单的“工程”-“引用”-找到Microsoft Excel 的lib库才可以运行
Dim ExApp As New Excel.Application
Dim Exb As Excel.Workbook
Dim Exsh As Excel.Worksheet
Dim R1 As Excel.Range
ExApp.Workbooks.Open "D\my ducuments\book1.xls"
Set Exb = ExApp.Workbooks(1)
Set Exsh = Exb.Worksheets("Sheet1")
Text1.Text = Exsh.Range("D4")
ExApp.Workbooks.Close
ExApp.Quit
Set ExApp = Nothing
End Sub
运行前要在菜单的“工程”-“引用”-找到Microsoft Excel 的lib库才可以运行
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询