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

📄 form1.frm

📁 VB essential experience VB essential experience
💻 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 Command2 
      Caption         =   "end"
      Height          =   435
      Left            =   2400
      TabIndex        =   1
      Top             =   480
      Width           =   1575
   End
   Begin VB.CommandButton Command1 
      Caption         =   "excel"
      Height          =   495
      Left            =   480
      TabIndex        =   0
      Top             =   480
      Width           =   1575
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
 
 Option Explicit
 Dim xlapp As Excel.Application
 Dim xlbook As Excel.Workbook
 Dim xlsheet As Excel.Sheets
 

Private Sub Command1_Click()
 If Dir("D:\temp\excel.bz") = "" Then
 Set xlapp = CreateObject("excel.application")
 xlapp.Visible = True
 Set xlbook = xlapp.Workbooks.Open("D:\temp\bb.xls")
 Set xlsheet = xlbook.Worksheets(1)
 xlsheet.Cells(1, 1) = "abc"
 xlbook.RunAutoMacros (xlAutoOpen)
 Else
 MsgBox ("excel已打开")
 End If
 



End Sub

Private Sub Command2_Click()
If Dir("D:\temp\excel.bz") <> "" Then
xlbook.RunAutoMacros (xlAutoClose)
xlbook.Close (True)
xlapp.Quit
End If
Set xlapp = Nothing '释放EXCEL对象
  End



End Sub

⌨️ 快捷键说明

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