回覆列表
  • 1 # 我是阿嘛

    Private Sub Command1_Click()

    Dim A As Integer

    Dim scxls As New excel.Application

    Dim scbook As excel.Workbook

    Dim scsheet As excel.Worksheet

    Set scxls = CreateObject("excel.application") "建立EXCEL物件

    scxls.DisplayAlerts = False "不顯示對話方塊,如果D:\2\1\3.xls檔案已存在,讓它不出現這個提示,就需加這段程式碼。

    Set scbook = scxls.Workbooks.Open("D:\2\4.xls")

    "Set scbook = scxls.Workbooks.Add "新建EXCEL工件簿檔案

    Set scsheet = scbook.Worksheets(1) "設定活動工作表

    scxls.Visible = True "顯示Excle

    Text1.Text = scsheet.Cells(2, 2) "讀取資料 並在text1裡顯示

    Text2.Text = scsheet.Cells(2, 6) "讀取資料 並在text1裡顯示

    scsheet.SaveAs ("D:\2\1\3.xls") "excel 存檔 語法:表示式.SaveAs(FileName, FileFormat, Password, WriteResPassword, ReadOnlyRecommended, CreateBackup, AccessMode, ConflictResolution, AddToMru, TextCodepage, TextVisualLayout, Local)

    scxls.Quit "excel 關閉

    End Sub

  • 中秋節和大豐收的關聯?
  • 為什麼有些人不喜歡丁真?