AUTOMATING YOUR CHARTS Using VBA or C Automation

AUTOMATING YOUR CHARTS Using VBA or C#

Automation Methods /// Return true if shape is a Mekko. Graphics chart bool Is. Mekko. Chart(Power. Point. Shape sh); /// This function will open the provided Mekko Graphics chart for editing void Edit. Mekko. Chart(Power. Point. Shape sh); /// This function will save and close the currently opened Mekko Graphics chart void Save. And. Close. Mekko. Chart(); /// This function returns True if the provided Shape is a Mekko Graphics chart bool Is. Mekko. Chart(Power. Point. Shape sh); /// This function will extract the chart data from the currently opened Mekko Graphics chart string[, ] Get. Opened. Chart. Data(); /// This function will extract the chart data from the provided Mekko Graphics chart string[, ] Get. Chart. Data(Power. Point. Shape shape); /// This function will inject the chart data into the currently opened Mekko Graphics chart void Set. Opened. Chart. Data(string [, ] data); /// This function will inject the chart data into the provided Mekko Graphics chart Power. Point. Shape Set. Chart. Data(Power. Point. Shape shape, string[, ] data); /// This function will refresh the Excel Link (if any) for the provided Mekko Graphics chart bool Refresh. Excel. Link(Power. Point. Shape shape); /// This function will Update the provided Mekko Graphics chart bool Refresh. Chart(Power. Point. Shape shape); /// Replaces entire Chart. Data. Array void Replace. Opened. Chart. Data. Array(string[, ] data); /// Replaces entire Chart. Data. Array for shape Power. Point. Shape Replace. Chart. Data. Array(Power. Point. Shape shape, string[, ] data);

VBA Sample Code Switch to Microsoft Visual Basic Editor (Alt+F 11) to see more code samples // VBA Sub Update. Selected. Chart() Dim add. In As COMAdd. In Dim MG_utilities As Object Dim sel As Selection Dim sh As Shape Set add. In = Application. COMAdd. Ins("Mekko. Graphics. Addin") Set MG_utilities = add. In. Object If (MG_utilities Is Not Null) Then Set sel = Active. Window. Selection If (sel. Shape. Range. Count = 1) Then Set sh = sel. Shape. Range(1) If (MG_utilities. Is. Mekko. Chart(sh)) Then MG_utilities. Refresh. Chart (sh) End If End Sub

C# Interface public interface IAdd. In. Utilities { void Edit. Mekko. Chart(Power. Point. Shape sh); void Open. Task. Panes(Power. Point. Shape sh); void Save. And. Close. Mekko. Chart(); bool Is. Mekko. Chart(Power. Point. Shape sh); string[, ] Get. Opened. Chart. Data(); string[, ] Get. Chart. Data(Power. Point. Shape shape); /// <summary> /// Only Replaces corresponding cell values in Chart. Data. Array if cells and valueas are not empry. Does not change size of Chart. Data. Array /// </summary> void Set. Opened. Chart. Data(string[, ] data); /// <summary> /// Only Replaces corresponding cell values in Chart. Data. Array if cells and valueas are not empry. Does not change size of Chart. Data. Array /// </summary> Power. Point. Shape Set. Chart. Data(Power. Point. Shape shape, string[, ] data); /// <summary> /// Replaces entire Chart. Data. Array /// </summary> /// <param name="shape"></param> /// <param name="data"></param> /// <returns></returns> void Replace. Opened. Chart. Data. Array(string[, ] data); /// <summary> /// Replaces entire Chart. Data. Array /// </summary> /// <param name="shape"></param> /// <param name="data"></param> /// <returns></returns> Power. Point. Shape Replace. Chart. Data. Array(Power. Point. Shape shape, string[, ] data); bool Refresh. Excel. Link(Power. Point. Shape shape); bool Refresh. Chart(Power. Point. Shape shape); bool Convert. Chart(Power. Point. Shape shape); }

C# Sample Code // C# // First set a reference to Mekko. Addin 10. dll located in the Mekko Graphics installation folder public void Update. Selected. Chart(Office. IRibbon. Control control) { object add. In. Name = "Mekko. Graphics. Addin"; Office. COMAdd. In add. In = Globals. This. Add. In. Application. COMAdd. Ins. Item(ref add. In. Name); Wizard. Addin. IAdd. In. Utilities MG_utilities = (Wizard. Addin. IAdd. In. Utilities)add. In. Object; if (MG_utilities != null) { Power. Point. Document. Window dw = Globals. This. Add. In. Application. Active. Window; Power. Point. Selection sel = dw. Selection; if (sel. Shape. Range. Count == 1) { Power. Point. Shape sh = sel. Shape. Range[1]; if (MG_utilities. Is. Mekko. Chart(sh)) MG_utilities. Refresh. Chart(sh); } } }
- Slides: 5