回覆列表
  • 1 # dadazhu1

    1.部件-新增-可插入物件--選擇excel 表格就可以在窗體新增該表格控制元件

    2.工程-引用-Microsoft Excel 11.0 Object Library

    下面給個簡單的例子

    Private Sub Command1_Click()

    Dim xlExcel As Excel.Application

    Dim xlBook As Excel.Workbook

    Dim xlSheet As Excel.Worksheet

    Dim AppExcel As Object

    Set xlExcel = CreateObject("Excel.Application")

    xlExcel.Workbooks.Open "C:\test.xls"

    Set xlBook = xlExcel.Workbooks("test.xls")

    Set xlSheet = xlBook.Worksheets(1)

    Text1.Text = xlSheet.Cells(1, 1).Value

    Text1.Text = Text1.Text & "ADD"

    xlSheet.Cells(1, 1).Value = Text1.Text

    Application.DisplayAlerts = False

    xlBook.Close SaveChanges:=True

    Application.DisplayAlerts = True

    End Sub

  • 中秋節和大豐收的關聯?
  • 青鳥告訴我們什麼道理?