Q:

VBA Test for Object Model

I'm trying to write a PPT macro that will work in both PPT 2010 and 2013-2016.  There is one object in the 2013-16 Object Model (ActivateChartDataWindow) that is not in the 2010 model that I want to use.  I thought of using code like this to test the application version and then use the correct object:
With theChart.ChartData
    If CInt(Application.Version) >= 15 Then
        .ActivateChartDataWindow
    Else
        .Activate
    End If
....
End With

The problem is this won't compile in 2010 since the .ActivateChartDataWindow object is not found.  So there wouldn't be run-time error, but there is a compile-time error.
What's the best way to do this?  Is there a way to disable compile-time checking in the code itself?

A:

You're making an early-bound member call; if the code contains member calls that can't be compiled using an earlier version of a type library, then the solution is to switch to late-bound calls, which by definition are only bound at run-time (i.e. no compile-time validation).
So instead of With theChart.ChartData, you declare an Object variable, and Set it to theChart.ChartData:
Dim lateBoundChartData As Object
Set lateBoundChartData = theChart.ChartData

And now any member calls made against that lateBoundChartData will only be validated at run-time - watch out for typos, Option Explicit can't help you here!
With lateBoundChartData
    If CInt(Application.Version) >= 15 Then
        'no intellisense & compile-time validation here
        .ActivateChartDataWindow
    Else
        'no intellisense & compile-time validation here
        .Activate
    End If
End With

The funny thing is that people write late-bound code all the time, without even realizing: anything you write against Object is always going to be late-bound.

