The think-cell API (WIP)
- Home
- Resources
- User manual
- The think-cell API (WIP)
On Windows, you can program some think-cell functions through the think-cell API. This appendix contains an overview of all available API functions and general instructions for setting up your development environment to write macros, add-ins, or standalone programs that access these functions.
Get started with the think-cell API
The think-cell API is integrated into Microsoft's Component Object Model (COM), so you can access the API from any language with which you can program Office, such as Visual Basic for Applications (VBA) or C#.
The entry point into think-cell is the think-cell add-in object. It can be accessed via the Application.COMAddIns
collection. Calls into think-cell are always late-bound, thus there is no type library or reference to add. For an explanation of early and late binding in Automation, see Microsoft Learn.
Some API functions are methods of the think-cell add-in object in PowerPoint, and other API functions are methods of the think-cell add-in object in Excel. We use tcPpAddIn
for references to the PowerPoint add-in, and tcXlAddIn
for references to the Excel add-in.
Visual Basic for Applications
To write macros using Visual Basic for Applications (VBA), you use the development environment integrated into the Office host application. This can be accessed by pressing Alt+F11. The definition of a macro is usually contained in a module, which you can add via Insert > Module. You can view all macros defined for a given document by pressing Alt+F8.
To indicate that method calls into the think-cell add-in are late-bound, you need to declare the variable containing the reference to it as Object
:
Dim tcaddin As Object
Set tcaddin = Application.COMAddIns("thinkcell.addin").Object
The type library for the Office host application is always referenced by default. If you need to access the object model of another Office application, you need to add its type library as a reference.
For example, if you want to use a macro in PowerPoint to manipulate data in an Excel sheet before updating a think-cell chart from it, you need to manually add the Microsoft Excel 16.0 Object Library via the Tools > References dialog in the VBA development environment.
Note: 16.0 is the version number of Office 2016 and later. For Office 2013, you need to use the 15.0 object library. If you have multiple versions of Office installed, the References dialog will only show the object libraries of the latest version installed. We will assume in the following that you are using Office 2016 or later.
Using Application.COMAddIns("thinkcell.addin").Object
will always get you the think-cell add-in object of the current Office host application, that is tcPpAddIn
or tcXlAddIn
, depending on whether you use it in PowerPoint or Excel. To acquire a reference to the add-in object in the other Office application, and access the API functions it exposes, acquire it through an appropriate application instance.
For example, to acquire a reference to tcXlAddIn
from PowerPoint:
Dim xlapp As Object
Set xlapp = New Excel.Application
Dim tcXlAddIn As Object
Set tcXlAddIn = xlapp.COMAddIns("thinkcell.addin").Object
Note that this requires the Excel object library to be added as as a reference.
We recommend using the Option Explicit
statement, which forces the explicit declaration of all variables, thereby helping to avoid common programming errors and improving the suggestions provided by IntelliSense. You can have it automatically added to all modules by activating Tools > Options > Code Settings > Require Variable Declaration. It is included in all our code samples.
C#
You can use the think-cell API from C# when developing add-ins and document code extensions running inside an Office host application, as well as when developing standalone applications.
We will assume in the following that you are using Visual Studio 2017 or later to develop Office solutions in C#. Refer to the next section for more specific setup instructions for add-in development. With each of our code samples, we will indicate which Visual Studio project template to use.
To make method calls to the think-cell add-in object late-bound, declare the variable containing the reference to the think-cell add-in object as dynamic
; this is also the type inferred by the compiler when declaring the reference as var
, so that you can simply write:
var tcPpAddIn = ppapp.COMAddIns.Item("thinkcell.addin").Object;
Here ppapp
is a reference to a PowerPoint Application
object in which think-cell is loaded.
To access the object model of an Office application, you need to add either its type library or its primary interop assembly (PIA) as a reference to your project. We recommend adding the type library if possible, since Visual Studio will automatically add a reference to the corresponding PIA, if one is available, or generate an interop assembly from the type library if there is none (see here).
For example, to be able to get the reference to the think-cell add-in object as above, you would add the Microsoft PowerPoint 16.0 Object Library found in the COM > Type Libraries tab of the Reference Manager dialog. Depending on your project type, this dialog is accessed either by right-clicking References or Dependencies in the Solution Explorer and selecting Add (COM) Reference.
Note: 16.0 is the version number of Office 2016 and later. By using the Embed Interop Types option, which is enabled by default for a reference to a COM type library, an application compiled with this reference will be backward (and forward) compatible with other versions of Office as long as all interfaces used exist in their object model. See here for more information.
think-cell's API functions indicate errors using COM HRESULT
s. Some of these are automatically mapped onto corresponding .NET exception classes, see How to: Map HRESULTs and Exceptions .
Add-in development
To develop add-ins for Office, or code extensions for Office documents, you use the PowerPoint/Excel VSTO Add-in and Excel VSTO Template/Workbook project templates. These are part of the Office Developer Tools for Visual Studio, which are installed as part of the default configuration. Should these tools and templates not be available in your Visual Studio installation, you can add them, for example, by going to Settings⚙ > Apps > Visual Studio 2022 > Modify > Other Toolsets, checking Office/SharePoint development and clicking Modify. See also Microsoft's documentation here and here.
The PIA for the Office host application of the selected template is always loaded by default. If you need to access the object model of another Office application, you need to add its type library as a reference as explained above.
Note: think-cell's API cannot be used from Office Web Add-Ins—unfortunately now simply called "Office Add-ins" by Microsoft—as they cannot interact with the Office application's object model directly, and in particular cannot interact with COM add-ins such as think-cell.
API reference
On Windows, you can use the following APIs:
Automation with Excel data
Automatically update think-cell elements in a PowerPoint template with data from Excel. To learn more, see Automation with Excel data (WIP).
API |
Description |
Manual topic |
---|---|---|
|
Updates all think-cell elements in a PowerPoint template that are linked to an Excel workbook |
|
|
Updates specific think-cell elements in a PowerPoint template, regardless of whether they are linked to Excel |
|
|
Updates a think-cell element in a PowerPoint template with data from Excel. |
Style files
Load, view, and remove think-cell style files. To learn more, see Style files (Preview).
API |
Description |
Manual topic |
---|---|---|
|
Loads a style file in a slide master or slide layout |
|
|
Loads a style file so that it applies only to a specific area of a slide layout |
Load a style file in an area of the layout: LoadStyleForRegion |
|
Returns the name of the style file that is active in a slide master or slide layout |
|
|
Removes all style files from a slide layout |
Mekko Graphics charts
Import Mekko Graphics charts to think-cell and inspect them. To learn more, see Import Mekko Graphics charts (Preview).
API |
Description |
Manual topic |
---|---|---|
|
Replaces Mekko Graphics charts in PowerPoint with think-cell charts |
|
|
Extracts the XML definition of a Mekko Graphics chart |
- Get started (WIP)
- think-cell Core: Presentation basics (TO DO)
- think-cell Charts: Data visualization
- think-cell Library: Presentation resources
- Deployment guide
- The think-cell API (WIP)