Link to home
Start Free TrialLog in
Avatar of Jamie Garroch (MVP)
Jamie Garroch (MVP)Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Differentiating and using Office.ColorFormat object versus PowerPoint.ColorFormat

I have a procedure running in the PowerPoint VBE that checks various properties of a chart shape. For example, let's take the ChartTitle object which is essentially a text box.

I am passing the ColorObject of the shape fill and font fill of the ChartTitle text box to a function to check its properties with these lines:

CheckColor oCht.ChartTitle.Format.Fill.ForeColor
CheckColor oCht.ChartTitle.Format.TextFrame2.TextRange.Font.Fill.ForeColor

Open in new window

The function signature looks likes this:
Function CheckColor(thisColor as ColorFormat)

Open in new window

The problem is that the second call to the function fails with a Type Mismatch error. Both objects used in calling the function return "ColorFormat" when I use TypeName to inspect them.

I then tried modifying the function to use the Office library:

Function CheckColor(thisColor as Office.ColorFormat)

Open in new window

Now the second call to the function works but the first doesn't.

So, how can I tell which library an object in VBA belongs to and how can I manage the above situation when different parts of the object model appear to be using different libraries?
ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jamie Garroch (MVP)

ASKER

Very good Rgonzo1971. I actually thought about declaring it as Object a few minutes after I posted it but hadn't thought about using the error trapping method you've used.Nice!  Just out of interest, why did you choose Variant instead of Object as the data type?
Avatar of Rgonzo1971
Rgonzo1971

Simply didn't thought too much about it but variant implies flexibility