回覆列表
  • 1 # gegrp27145

    下面程式碼把c:\1.xls中Sheet1工作表的內容複製到另外一個新建工作表中,並儲存為“c:\2.xls”Private Sub Command1_Click()Dim S() As String, i As Integer, j As IntegerDim xlAppDim xlBookDim xlSheetSet xlApp = CreateObject("Excel.Application") "建立EXCEL物件xlApp.DisplayAlerts = False "不顯示對話方塊Set xlBook = xlApp.Workbooks.open("c:\1.xls") "開啟已經存在的EXCEL工件簿檔案xlApp.Visible = True "設定EXCEL物件可見(或不可見)Set xlSheet = xlBook.Worksheets("Sheet1") "設定活動工作表xlSheet.Cells.Select xlSheet.Cells.Copy xlApp.Workbooks.Add xlApp.ActiveSheet.Paste xlApp.Application.CutCopyMode = False xlApp.ActiveWorkbook.SaveAs FileName:="c:\2.xls" "儲存工作表,結束時一定別忘了儲存xlBook.Close (True) "關閉工作簿 這裡的True表示退出時儲存修改xlApp.Quit "結束EXCEL物件Set xlApp = Nothing "釋放xlApp物件End Sub

  • 中秋節和大豐收的關聯?
  • 開具完的紅字發票怎麼處理?