Excel VBA编程基础

来源:互联网 发布:手机淘宝如何申请介入 编辑:程序博客网 时间:2024/05/21 22:44

一、程序基本调试方法

1、VB程序的三种状态:设计时、运行时和中断模式。

2、但不执行代码,快捷键为F8。

3、中断程序的方法:

(1)使用断点

(2)使用Debug.Assert

(3)使用监视条件

二、Excel Shape对象








三、制作带“自杀”功能的工作簿

step1、 设置只读属性

step2、删除文件

setp3、demo

(1)打开时自杀


(2)利用文档属性名自杀

Option ExplicitSub ReadOpenTimes()    Dim times As Integer        With Me            times = .CustomDocumentProperties("OpenTimes").Value + 1        If times > 3 Then            Call killme        Else            .CustomDocumentProperties("OpenTimes").Value = times            .Save        End If    End WithEnd SubSub killme()    With ThisWorkbook        .Saved = True        .ChangeFileAccess xlReadOnly        Kill.FullName        .colse    End WithEnd Sub

四、

五、

0 0