1

I am very new to PowerPoint add-on development so please bear with me.

There are many objects that can be inserted into a PowerPoint slide, such as text box, shape, chart, etc. Is there a way to build my own custom object with custom properties and functionalities? For example, with the Thinkcell add-on, you can insert a Thinkcell chart object, connect it to Excel workbook, edit it, and show it. To the best of my understanding, this is a kind of custom object built into the Thinkcell add-on.

How can I build a custom object like this?

I have checked some tutorials on building a PowerPoint add-on with VBA, VSTO, and Javascript. To the best of my understanding, these technologies allow users to build some user interfaces to interact and modify the PowerPoint slides, such as creating and modifying elements in the slides. However, I don't see examples of creating a custom object using these technologies. Thus I am very curious about how add-ons create their custom element.

Thanks!

Andy
  • 11
  • 2
  • Cross-posted at https://learn.microsoft.com/en-us/answers/questions/1133101/how-to-program-a-powerpoint-custom-object-like-thi.html – John Korchok Dec 18 '22 at 19:13

2 Answers2

0

First, you will need to install the necessary npm packages and set up the development environment.

For example, you can use the following command to install the Office.js library:

npm install @microsoft/office-js

Then, you can use the following code to create a custom object in a PowerPoint add-in:

Office.initialize = function () {
  // Create a new shape on the active slide
  var shape = PowerPoint.createShape("MyCustomObject", Office.MsoAutoShapeType.msoShapeRectangle, 50, 50, 100, 100);

  // Add a custom property to the shape
  shape.customProperties.add("dataSource", "Excel workbook");

  // Define a function to be called when the user clicks on the shape
  shape.click = function () {
    // Open the Excel workbook and display the data
    Office.context.ui.displayDialogAsync("https://example.com/excel-workbook", {height: 50, width: 50});
  };
};
 
hiFI
  • 1,887
  • 3
  • 28
  • 57
  • Thank you so much for your reply! Does it mean that custom objects (like a Thinkcell object) are actually PowerPoint built-in objects (like text box, charts, shapes) just with customer properties and callbacks registered? – Andy Dec 18 '22 at 06:48
  • If so, I imagine the color, text, settings, etc of a Thinkcell object are just the custom properties of the object. How can I program the object such that it displays in a certain way according to the properties? – Andy Dec 18 '22 at 07:00
0

Here is how you might accomplish this using VBA:

Sub ChangeObjectColor()
Dim obj As Shape

' Get a reference to the custom object
Set obj = ActivePresentation.Slides(1).Shapes("MyObject")

' Check the value of the FillColor property
If obj.FillColor = "red" Then
' Set the fill color of the object to red
obj.Fill.ForeColor.RGB = RGB(255, 0, 0)
ElseIf obj.FillColor = "green" Then
' Set the fill color of the object to green
obj.Fill.ForeColor.RGB = RGB(0, 255, 0)
End If
End Sub
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83