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?
I am looking at 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. By reading the associated documentation as well.
The only way I think that's possible is by having a structured document like 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
Update: Based on entry by user Oliver below: My office help doesn't seem to be working.
Generally, if a variable or other identifier can be resolved to a specific type, then Intellisense will show you the members of that type. 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.
You can discover the underlying type of the object which Selection
refers to, by adding a watch ( Debug -> Add Watch... ). Type Selection
in the Expression box, and set the context to (All Procedures) and (All Modules) if it's not set that way already.
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. 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
. 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.
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.
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. ?
-- eg ?ActiveWorkbook.Sheets.Count
) and run code in place (such as ActiveWorkbook.Save
) The Excel Developer reference is most probably right on your computer, it's just difficult to find:
Manual way:
Now you are looking at the Excel-VBA Help and you can even search it in the top left box for "Selection".
Direct Link:
"C:Program Files (x86)Microsoft OfficeOffice15CLVIEW.EXE" "EXCEL.DEV" "Microsoft Office Excel"
(At least this worked for Office 2007, i assume it does for 2013 as well)
Do you mean, while coding you would like to see function/sub explanations like JavaDoc? Unfortunately this is not standard in VBA.
However you might want to take a look into this Is there a good VB6 documentation system similar to Javadoc?
链接地址: http://www.djcxy.com/p/75444.html上一篇: 如何使用OpenXML创建Excel文件而不创建本地文件?
下一篇: VBA对象模型参考文档