[英]VBA Object Model reference documentation
Is there a place where I can simply find the Object Model hierarchy and kind of API for VBA for Excel 2013?有没有一个地方可以简单地找到对象模型层次结构和 VBA for Excel 2013 的 API 种类?
I am looking at MSDN URL http://msdn.microsoft.com/en-us/library/office/ff841127(v=office.15).aspx我正在查看 MSDN URL http://msdn.microsoft.com/en-us/library/office/ff841127(v=office.15).aspx
But that seems confusing.但这似乎令人困惑。
Example:例子:
If I am writing如果我在写
Selection.Interior.ColorIndex = -4142
I would like to have an API (online or offline) to understand the Object Models starting with Selection
and work (and explore) my way to ColorIndex.我想要一个 API(在线或离线)来了解从
Selection
开始的对象模型,并以我的方式工作(和探索)到 ColorIndex。 By reading the associated documentation as well.通过阅读相关的文档。
The only way I think that's possible is by having a structured document like Java Docs.我认为这是可能的唯一方法是拥有像 Java Docs 这样的结构化文档。
Any references/tips will help.任何参考/提示都会有所帮助。
System Info:
MS Excel 2013
VBA
Windows 8, 64 bit
UPDATE: While searching for answers, I got the below image from http://msdn.microsoft.com/en-us/library/aa141044.aspx更新:在寻找答案时,我从http://msdn.microsoft.com/en-us/library/aa141044.aspx得到了下面的图片
Update: Based on entry by user Oliver below: My office help doesn't seem to be working.更新:根据以下用户 Oliver 的输入:我的办公室帮助似乎不起作用。
Generally, if a variable or other identifier can be resolved to a specific type, then Intellisense will show you the members of that type.通常,如果变量或其他标识符可以解析为特定类型,则 Intellisense 将向您显示该类型的成员。 For example:
例如:
Application.
will bring up a list of members.将显示成员列表。
Selection
is a special case because although the currently selected item is often a range of cells, it could be something else as well - part of a chart sheet for example. Selection
是一种特殊情况,因为尽管当前选定的项目通常是一系列单元格,但它也可能是其他内容 - 例如图表工作表的一部分。
You can discover the underlying type of the object which Selection
refers to, by adding a watch ( Debug -> Add Watch... ).您可以通过添加监视( Debug -> Add Watch... )来发现
Selection
所指对象的基础类型。 Type Selection
in the Expression box, and set the context to (All Procedures) and (All Modules) if it's not set that way already.在表达式框中键入
Selection
,并将上下文设置为(所有过程)和(所有模块)(如果尚未设置为这种方式)。
In the Watches window, you will see the actual type of the object referred to by Selection
, and you can expand the +
to see its properties.在Watches窗口中,您将看到
Selection
引用的对象的实际类型,您可以展开+
以查看其属性。 If the type says Object/Range
, (meaning the type of the expression is Object
and the type of the object referred to by the expression is Range
), one of the properties will be Interior
.如果类型为
Object/Range
,(意味着表达式的类型是Object
并且表达式引用的对象的类型是Range
),则属性之一将是Interior
。 If you look at the type column for Interior
, you'll see Interior/Interior
, because the type of the Interior
property is indeed the Interior
type.如果您查看
Interior
的类型列,您会看到Interior/Interior
,因为Interior
属性的类型确实是Interior
类型。
If you type the following in code:如果您在代码中键入以下内容:
ActiveCell.
Intellisense will show you a list of members, including the Interior
property, because the type of the ActiveCell
property is the Range
type. Intellisense 将向您显示成员列表,包括
Interior
属性,因为ActiveCell
属性的类型是Range
类型。
Some other powerful tools for investigating the object model:其他一些用于研究对象模型的强大工具:
<globals>
type can be used without any object references -- Interior
needs some Range
object to be used, but Selection
can be used by itself. <globals>
类型的成员可以在没有任何对象引用的情况下使用—— Interior
需要使用一些Range
对象,但Selection
可以单独使用。?
-- eg ?ActiveWorkbook.Sheets.Count
) and run code in place (such as ActiveWorkbook.Save
)?
-如?ActiveWorkbook.Sheets.Count
)和运行代码的地方(如ActiveWorkbook.Save
)The Excel Developer reference is most probably right on your computer, it's just difficult to find: Excel Developer 参考很可能就在您的计算机上,只是很难找到:
Manual way:手动方式:
Now you are looking at the Excel-VBA Help and you can even search it in the top left box for "Selection".现在您正在查看 Excel-VBA 帮助,您甚至可以在左上角的框中搜索“选择”。
Direct Link:直接链接:
"C:\Program Files (x86)\Microsoft Office\Office15\CLVIEW.EXE" "EXCEL.DEV" "Microsoft Office Excel"
(At least this worked for Office 2007, i assume it does for 2013 as well) (至少这适用于 Office 2007,我认为它也适用于 2013 年)
Do you mean, while coding you would like to see function/sub explanations like JavaDoc?您的意思是,在编码时您希望看到像 JavaDoc 这样的函数/子解释吗? Unfortunately this is not standard in VBA.
不幸的是,这不是 VBA 的标准。
However you might want to take a look into this Is there a good VB6 documentation system similar to Javadoc?但是你可能想看看这个是否有一个类似于 Javadoc 的好的 VB6 文档系统?
Another way to "see" the underlying Object Model called by Excel is to use the macro recorder. “查看”Excel 调用的底层对象模型的另一种方法是使用宏记录器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.