Home Ask Login Register

Developers Planet

Your answer is one click away!

Dhay February 2016

where can we get documentation for component object model

I want COM documentation if there is any as I want to know all even little things about COM. For example, as a common rule, converting below code for word application


to COM as


is easy just by adding object variable oWord. But how can we know that converting below VBA

Selection.Font.Color = 16711680

to below COM

oWord.Selection.Font.Color := wdColorBlue := 16711680

How := wdColorBlue := 16711680 comes?

I thought it should be either := wdColorBlue or := 16711680. But I couldn't imagine it is := wdColorBlue := 16711680.

Where can we find these little details?

Reference URL: https://autohotkey.com/board/topic/120360-changing-font-type-color-size-with-1-set-of-code-across-all-ms-office-programs/


Cindy Meister February 2016

"Translating" Office object models from the native VBA to use in other language environments can be tricky. Reading code snippets in the other language is a good way to get started - to get a "feel" for how it looks.

One important aspect to notice is that in some languages it's necessary to fully qualify the "namespace" from which something comes. For an Enumeration such as wdColorBlue, for example, the "parent" Enumeration may be necessary, which would be something like WdColor. (Note that the "parent" Enumeration in Word will always start with Wd, the enumeration elements start with wd.)

And in some languages you might need to specify the object model namespace, such as Word. Other languages, such as C#, need both: Microsoft.Office.Interop.Word.WdColor.wdColorBlue. (Or, if a using statement has been defined, like using Word = Microsoft.Office.Interop.Word then it would be Word.WdColor.wdColorBlue.)

When it comes to researching and using parts of the object model that aren't in code snippets, the VBA IDE does provide some tools that compliment what you can glean from the official Language References.

  • Object Browser The VBA IDE Object Browser can be accessed using F2 in the IDE (Alt+F11 to get to the IDE from within an Office application). Type the term you want to look at into the "Find" box and you'll get a list of corresponding object model elements. Clicking on an element brings up more information in the window below. At the very bottom is a gray section with additional details. For example, the "parent" Enumeration namespace for an Enum member such as wdColorBlue. Or a method's signature. (If you ever notice a conflict between Language Reference information and what you see in the Object Browser, the content of the Object Browser is correct!)
  • Immediate Window. You can also query information using the VBA

Post Status

Asked in February 2016
Viewed 2,639 times
Voted 5
Answered 1 times


Leave an answer

Quote of the day: live life