?? 讀取excel.frm
字號:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3090
ClientLeft = 60
ClientTop = 450
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3090
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command3
Caption = "Command3"
Height = 615
Left = 2520
TabIndex = 2
Top = 720
Width = 615
End
Begin VB.CommandButton Command2
Caption = "Command2"
Height = 375
Left = 720
TabIndex = 1
Top = 2400
Width = 975
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 615
Left = 3480
TabIndex = 0
Top = 2160
Width = 855
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Set ExcelApp = CreateObject("Excel.Application") '創(chuàng)建EXCEL對象
Set ExcelBook = ExcelApp.Workbooks.Add
Set ExcelSheet = ExcelBook.Worksheets(1) '添加工作頁
ExcelSheet.Activate '激活工作頁
ExcelApp.DisplayAlerts = False
ExcelSheet.Name = "sheet1"
ExcelSheet.Range("A1").Value = 100 '設(shè)置A1的值為100
ExcelSheet.Range("A2").Value = 200
ExcelBook.SaveAs "D:\VB\讀取excel\test.xls" '保存工作表
MsgBox "d:D:\VB\讀取excel\test.xls創(chuàng)建成功!"
ExcelBook.Close
Set ExcelApp = Nothing
Set ExcelBook = Nothing
Set ExcelSheet = Nothing
End Sub
Private Sub Command2_Click()
Set ExcelApp = CreateObject("Excel.Application") '創(chuàng)建EXCEL對象
Set ExcelBook = ExcelApp.Workbooks.open("d:\VB\讀取excel\test.xls")
Set ExcelSheet = ExcelBook.Worksheets(1)
MsgBox ExcelSheet.Range("A1").Value
End Sub
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -