Import Mekko Graphics charts (Preview)

Import Mekko Graphics charts

Conveniently import Mekko Graphics charts and their data to think-cell.

The Import Mekko Graphics to think-cell tool converts Mekko Graphics charts to think-cell charts. You do not need Mekko Graphics installed to use the importer tool.

To import Mekko Graphics charts to think-cell, follow these steps:

  1. In PowerPoint, select one or more Mekko Graphics charts on a slide, or select slides containing Mekko Graphics charts.
  2. On the ribbon, select think-cell > Elements > Tools Tools Menu icon > Import Mekko Graphics to think-cell or Insert > think-cell > Tools Tools Menu icon > Import Mekko Graphics to think-cell.

Once you select Import Mekko Graphics to think-cell, think-cell replaces the Mekko Graphics charts that you selected with think-cell charts. All other slide content remains the same. After each slide where you replaced Mekko Graphics charts, think-cell inserts a backup slide with the original Mekko Graphics charts.

You can import most Mekko Graphics charts to think-cell, with the following exceptions:

  • Gantt, floating bar, and horizontal floating bar charts
  • Other Mekko Graphics elements, like Harvey balls

If a Mekko Graphics chart or element can't be imported, think-cell displays a message.

Import charts with data rows or columns

If a Mekko Graphics chart has data rows or columns, think-cell imports that chart as a think-cell chart with a data table (see Data tables). Mekko Graphics charts may represent the same data in both the data table and the chart. think-cell currently doesn't support representing the same data in both the data table and the chart. If a Mekko Graphics chart represents the same data in both the data table and the chart, think-cell will import that chart without a data table.

Style and format imported charts

think-cell doesn't import the style and formatting of Mekko Graphics charts. However, after importing a Mekko Graphics chart, it's easy to recreate the chart's style and formatting in think-cell.

Style charts

When think-cell imports a Mekko Graphics chart, the imported chart adopts the style and formatting of the active think-cell style file (see Set up think-cell style files). You can format and style imported charts like any other think-cell chart (see 🛇3.4 Format and style elements and Style and format charts).

The following image shows how to use the chart's context menu to add a Y-axis to an imported chart.

Use think-cell's context menu to add axis

Format numbers

Most number formatting in Mekko Graphics charts is not imported to think-cell charts. You can change number formatting easily in think-cell (see Format chart labels).

The following image shows how to use the mini toolbar to apply the currency number format of the original Mekko Graphics chart to the imported chart.

We recommend comparing your Mekko Graphics charts and imported charts to ensure that they are consistent with each other. Switch between the original and backup slides to compare and make any necessary changes to the imported charts. When you're satisfied with the imported charts, you can delete the backup slides.

Edit imported chart data

think-cell imports the data from a Mekko Graphics chart to the imported chart's datasheet. You can edit the data of an imported chart like that of any other think-cell chart (see Introduction to element datasheets).

Show hidden series or categories

think-cell imports the data from hidden series or categories in a Mekko Graphics chart as hidden rows or columns in the imported chart's datasheet. To show hidden series or categories in the imported chart, select the columns or rows that contain the hidden data in the chart's datasheet, right-click your selection, and select Unhide. To learn more, see Microsoft Support.

Automate the importing process

Windows only

On Windows, you can use think-cell API functions to programmatically import Mekko Graphics charts to think-cell or inspect them. ImportMekkoGraphicsCharts replaces Mekko Graphics charts with think-cell charts. GetMekkoGraphicsXML extracts the XML definition of a Mekko Graphics chart.

ImportMekkoGraphicsCharts

Description

This function replaces all Mekko Graphics charts in the array of shapes passed to it with an equivalent think-cell chart. All shapes must be on the same slide. Before modifying the slide, the function will make a copy of the unmodified slide and insert it directly after the modified version.

If the slide was not modified, for example because the array did not contain any Mekko Graphics charts, the function returns Nothing/null. Otherwise, the function returns a reference to the unmodified copy of the slide.

VBA
Signature
tcPpAddIn.ImportMekkoGraphicsCharts ( _
    ashp As PowerPoint.Shape() _
) As PowerPoint.Slide
Example

To use this example, add it to a module in PowerPoint. To learn more, see Visual Basic for Applications.

Running ImportAll on a presentation will go through the slides in the presentation and replace all visible Mekko Graphics charts with equivalent think-cell charts, making a copy of each slide containing Mekko Graphics charts before modifying it.

Option Explicit

Sub ImportAll()

    ' Get reference to think-cell Object

    Dim tcPpAddIn As Object
    Set tcPpAddIn = Application.COMAddIns("thinkcell.addin").Object

    ' Iterate over copy of original Slides to avoid
    ' iterating over copies inserted by ImportMekkoGraphicsCharts again

    Dim SlidesCopy As New Collection
    Dim Slide As PowerPoint.Slide
    For Each Slide In ActivePresentation.Slides
        SlidesCopy.Add Slide
    Next Slide
    
    For Each Slide In SlidesCopy
    
        ' Construct Array containing only visible shapes on slide
        
        Dim visibleShapes() As PowerPoint.Shape
        ReDim visibleShapes(1 To Slide.Shapes.Count)
        Dim shapeIndex As Long
        For shapeIndex = 1 To Slide.Shapes.Count
            If Slide.Shapes(shapeIndex).Visible Then
                Set visibleShapes(shapeIndex) = Slide.Shapes(shapeIndex)
            End If
        Next shapeIndex
        
        ' Pass Array to ImportMekkoGraphics and store return value
        
        Dim CopySlide As PowerPoint.Slide
        Set CopySlide = tcPpAddIn.ImportMekkoGraphicsCharts(visibleShapes)
        
        ' If Slide was modified...
        If Not CopySlide Is Nothing Then
        ' ... do things with copy of unmodified slide
        End If
    Next Slide
End Sub
C#
Signature
PowerPoint.Slide tcPpAddIn.ImportMekkoGraphicsCharts(
    PowerPoint.Shape[] ashp
);
Example

To use this example, in the C# PowerPoint VSTO Add-in project template, add this method to the ThisAddIn class. To learn more, see C# and Add-in development.

private void ImportAll(PowerPoint.Presentation presentation)
    {
        var tcPpAddIn = presentation.Application.COMAddIns.Item("thinkcell.addin").Object;
        foreach (PowerPoint.Slide slide in presentation.Slides.Cast<PowerPoint.Slide>().ToList())
        {
            PowerPoint.Slide slideCopy = tcPpAddIn.ImportMekkoGraphicsCharts(
                slide.Shapes.Cast<PowerPoint.Shape>().ToArray()
            );
        }
    }

To run ImportAll on each open presentation, add the following line to the ThisAddIn_Startup method.

Application.PresentationOpen += new PowerPoint.EApplication_PresentationOpenEventHandler(ImportAll);

GetMekkoGraphicsXML

Description

This function returns the XML code of the Mekko Graphics chart in shp as a string. It does not modify the shape passed to it.

If shp is not a Mekko Graphics chart, an E_INVALIDARG (0x80070057) error is raised.

VBA
Signature
tcPpAddIn.GetMekkoGraphicsXML ( _
    shp As PowerPoint.Shape _
) As String
Example

To use this example, add the following code to a module in PowerPoint. To learn more, see Visual Basic for Applications.

Option Explicit

Sub GetMekkoGraphicsXMLOfAllShapes()

    ' Get reference to think-cell Object

    Dim tcPpAddIn As Object
    Set tcPpAddIn = Application.COMAddIns("thinkcell.addin").Object

    ' Go through the slides in the presentation and
    ' output the XML of each Mekko Graphics chart on the slide
    ' to the debug console

    Dim slide As PowerPoint.slide
    For Each slide In Application.ActivePresentation.Slides
        Dim shape As PowerPoint.shape
        For Each shape In slide.Shapes
            On Error Resume Next ' skip over shapes that are not Mekko Graphics charts
            Debug.Print tcPpAddIn.GetMekkoGraphicsXML(shape)
        Next shape
    Next slide
End Sub
C#
Signature
string tcPpAddIn.GetMekkoGraphicsXML(
    PowerPoint.Shape shp
);
Example

To use this example, replace the code in Program.cs of a Console App with the example.

The sample requires references to the Microsoft PowerPoint 16.0 Object Library and Microsoft Office 16.0 Object Library (see C# for details).

Running the application will go through the presentation in C:\Samples\GetMekkoGraphicsXML\presentation.pptx and print the XML of the Mekko Graphics charts contained in the presentation to the console.

using PowerPoint = Microsoft.Office.Interop.PowerPoint;
using Office = Microsoft.Office.Core;

namespace Sample
{
    class Program
    {
        static void Main()
        {
            var ppapp = new PowerPoint.Application();
            var presentation = ppapp.Presentations.Open(
                "C:\\Samples\\GetMekkoGraphicsXML\\presentation.pptx",
                /*ReadOnly*/Office.MsoTriState.msoTrue,
                /*Untitled*/Office.MsoTriState.msoTrue,
                /*WithWindow*/Office.MsoTriState.msoFalse
            );

            var tcPpAddIn = ppapp.COMAddIns.Item("thinkcell.addin").Object;
            foreach (PowerPoint.Slide slide in presentation.Slides)
            {
                foreach (PowerPoint.Shape shape in slide.Shapes)
                {
                    string xml = tcPpAddIn.GetMekkoGraphicsXML(shape);
                    Console.WriteLine(xml);
                }
            }

            presentation.Close();
            ppapp.Quit();
        }
    }
}