當前位置:編程學習大全網 - 網站源碼 - VB 讀取Excel的內容

VB 讀取Excel的內容

'以下是源代碼:

'引用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

For i = 1 To 100

A(i) = xlsApp.ActiveCell.Offset(0, i - 1).Value

Print i;

Print " ";

Print A(i)

Next i

Set xlssheet = Nothing

Set xlsWorkbook = Nothing

Set xlsApp = Nothing

End Sub

  • 上一篇:完美國際靈機壹動:該找誰接任務?
  • 下一篇:mac os系統如何看 pydoc html報表
  • copyright 2024編程學習大全網