?'文件打開(kāi)窗口操作 intErrNum = Err.Number System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor txtExcelName.Text = CommonDialog1Open.FileName System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default End If ? ?'Excel操作,,可能參照中要增加excel類 Dim oExcel As Object Dim oBook As Object Dim oSheet As New Object Dim WSheetCount As Integer oExcel = CreateObject("Excel.Application") oBook = oExcel.Workbooks.Open(txtExcelName.Text, ReadOnly:=True) WSheetCount = oExcel.ActiveWorkbook.sheets.count For i = 1 To WSheetCount ’對(duì)Sheet1進(jìn)行操作 If oBook.Worksheets.Item(i).name() = “Sheet1”Then oSheet = oExcel.ActiveWorkbook.Sheets(WSheet) Exit For End If Next ’通過(guò)行列號(hào)對(duì)單元格進(jìn)行操作 oSheet.Cells(intRow, intColumn).Value oExcel.Application.DisplayAlerts = False |
|