VBA 学习笔记之– Excel 对象篇(一)
Excel 2013 版之后的本地帮助文档不见啦! 选中对象浏览器中内容按下F1会直接跳转到msdn的页面, 然后你会发现自己不停的各种页面直接跳来跳去,慢的蜗牛一样的微软服务器真心让人happy不起来.
在受够了卡成狗的Chrome和蹩脚的Excel 2013 Developer Documentation
https://www.microsoft.com/en-us/download/details.aspx?id=40326
本着自己动手丰衣足食的原则, 还是做笔记来的靠谱些.
それて、手帳を記入して始めましょう!
1. AddIn (AddIns,AddIns2)
第一个亮相的就是自动化的小能手, VBA开发的常用功能–加载项!
AddIn 是AddIns和AddIns2集合的成员, AddIns代表当前所有可用AddIn,无论是否载人Excel. AddIns2 还包含未在列表中,但已被Excel打开的加载宏.
属性:
- Name 加载项名称
- FullName 全名,即磁盘上的完整路径
- Path 路径, 所在位置.
- Installed 显示/设置AddIn是否装载入Excel程序
- IsOpen 显示Add-in是否已打开, 只读哟
- ProgID automation add-in用的 ,前面部分是通用名 最后的数字是版本号,布吉岛怎么用…
- CLSID 好吧 这个也不知道是做啥的 就是个唯一标识符
方法:
- expression .Add(Filename, CopyFile)
- Addins 和 Addins2 的Add方法有大同小异,只不过不支持Automation Add-in.
Name | Required/Optional | Data Type | Description |
---|---|---|---|
Filename | Required | String | The name of the file that contains the add-in or the ProgID of the automation add-in that you want to add to the list in the add-in manager. |
CopyFile | Optional | Variant | Ignored if the add-in file is on a hard disk. True to copy the add-in to your hard disk, if the add-in is on a removable medium (a floppy disk or compact disc). False to have the add-in remain on the removable medium. If this argument is omitted, Microsoft Excel displays a dialog box and asks you to choose. |
载入AddIn方法如下
AddIns.Add(addin_name).installed = True
; 将AddIn加入可用列表.
Workbooks.open(AddIn.FullName)
方法确保AddIn在当前程序中可用.
AddIns vs COMAddIns
COMAddIn 是 COM add-in的集合 两个加载项是分开哒, 引用的时候得区别.COM add-in 没有第二个集合, 因为不能用Excel直接打开, 只有注册了的组件才能使用. COM add-in 木有name属性,通过ProgID或者Guid引用. Connect属性显示是否当前被加载.
2. Adjustments
这是一个坑爹的设计!专门为自选图像设置调整值,其中每个调整值代表调整柄的调整方向,可是调整柄根本没有规律好么, 一个调整柄可能操纵两个调整值, 版本不同调整值的顺序也会不同,官方给出的结论是先试验一下. 画特殊图形的时候还是手动靠谱点儿.
调整柄类型如下: 一共仨,取值在0-1之间, 默认0.5
Type of adjustment | Valid values |
---|---|
Linear (horizontal or vertical) | Generally the value 0.0 represents the left or top edge of the shape and the value 1.0 represents the right or bottom edge of the shape. Valid values correspond to valid adjustments you can make to the shape manually. For example, if you can only pull an adjustment handle half way across the shape manually, the maximum value for the corresponding adjustment will be 0.5. For shapes such as connectors and callouts, where the values 0.0 and 1.0 represent the limits of the rectangle defined by the starting and ending points of the connector or callout line, negat |