⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 读取excel.frm

📁 用VB写的读取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") '创建EXCEL对象
Set ExcelBook = ExcelApp.Workbooks.Add
Set ExcelSheet = ExcelBook.Worksheets(1) '添加工作页
ExcelSheet.Activate '激活工作页
ExcelApp.DisplayAlerts = False
ExcelSheet.Name = "sheet1"
ExcelSheet.Range("A1").Value = 100 '设置A1的值为100
ExcelSheet.Range("A2").Value = 200
ExcelBook.SaveAs "D:\VB\读取excel\test.xls" '保存工作表
MsgBox "d:D:\VB\读取excel\test.xls创建成功!"
ExcelBook.Close
Set ExcelApp = Nothing
Set ExcelBook = Nothing
Set ExcelSheet = Nothing
End Sub

Private Sub Command2_Click()
Set ExcelApp = CreateObject("Excel.Application") '创建EXCEL对象
Set ExcelBook = ExcelApp.Workbooks.open("d:\VB\读取excel\test.xls")
Set ExcelSheet = ExcelBook.Worksheets(1)
MsgBox ExcelSheet.Range("A1").Value
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -