Solved

Is there any way to access "Smartart object model" in MS-Office 2007 (Word, PPT, Excel) using VBA macro/C#/C++ ?

Posted on 2009-04-09
6
3,123 Views
Last Modified: 2013-12-17
Hello Expert,

I want to extract information/properties of Smartart Graphics at runtime while an MS-Office document is opened.
So I need to access smartart object model of MS-Office 2007(Word, PPT, Excel) using VBA Macro/C#/Cplusplus.

Is there any way to access this Object model?

Thanks,
Ajit.
0
Comment
Question by:ashugarg00
6 Comments
 
LVL 21

Expert Comment

by:GlennaShaw
ID: 24132260
0
 

Accepted Solution

by:
ashugarg00 earned 0 total points
ID: 24948975
Actually there is no SmartArt model supported in MS Office 2007. But several properties we can extract like:

Selection in SmartArt
Each time when selection changes in document (Word, Power point, Excel), WindowSelectionChange -event is Fired by the Application. Selection of element can be get from COM and different for Each Application.
For Powerpoint,
1.      Total Number of Elements selected in Powerpoint = (ActiveWindow -> ActiveWindow ->Selection -> ShapeRange -> Count).
2.      Array of selected shape = (ActiveWindow -> ActiveWindow ->Selection -> ShapeRange -> items).
3.      If ActiveWindow -> ActiveWindow ->Selection -> ShapeRange -> item(i) == msoSmartArt, the element is SmartArt.
4.      To Uniquely identify the SmartArt (Shape), Id/Name attribute is used.
5.      Up to now we are able to get the selection of the parent element of SmartArt. To Get the selection about the child element.
a.      If ActiveWindow -> ActiveWindow ->Selection-> hasChildShapeRange == true, then some child is selected in the Smartart, else not.
b.      Array of the SmartArt child elements  = (ActiveWindow -> ActiveWindow ->Selection -> ChildShapeRange->items).
c.      Count of Array of SmartArt elements = (ActiveWindow -> ActiveWindow ->Selection -> ChildShapeRange->Count).
d.      Z-order is unique for each shape, We can use it to identify the child shape.
For Word,
Two types of Smartart element are available in Word: Inline & Floating.
Inline SmartArt (WdInlineShapeSmartArt):
1.      Array of Inline Shape = (Application -> ActiveDocument -> InlineShapes -> items). For count of inline shapes use Count Property.
2.      If item-> type == WdInlineShapeSmartArt, Smartart inline found.
To indentify uniquely this inline shape, use Range property (Value of Start & End property). Id property is not associated with these shapes.
3.      For Child Selection read the Powerpoint Module.
Floating Smartart (msoSmartArt):
1.      Array of Shapes = (Application -> ActiveDocument -> Shpaes -> items).
2.      If item->type == msoSmartArt, Floating SmartArt fount. Id property is used to uniquely identify the element.
3.      For Child, same as in the Power point.
For Excel,
I think there is one or more solution possible to get the selection in SmartArt. Below is shown one solution:
1.      Selection object = (Application -> Selection)
2.      Get the type of selected element, If Type == msoAutoShape, selected element is Shape && If Child == true, selected element is Child element. If it is having ParentGroup property, check the Type property. If Type == msoSmartArt, we are sure about the Smartart element selection.
3.      Child element in Smartart is uniquely identified by its Z-order.
4.      If Single element is selected then ParentGroup is outside the element
5.      Selection element count = (Application -> Selection -> Count).
6.      If Count >= 1, check ParentGroup of each element, it will give details of the Smartart element.
7.      Access the selection object from following Class type, else you will not be able to get the property details.
1.      Single child selection type = Shape.
2.      Multiple child selection type = ShapeRange.
3.      No Child Selection type = GroupObject.
0
 

Expert Comment

by:ljw2006
ID: 35874316
Is there an updated answer to this question?
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
My experience with Windows 10 over a one year period and suggestions for smooth operation
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now