Add support for shapes on Word Office.JS API

Add support for shapes on Word Office.JS API
2

Upvotes

Upvote

 Mar 01 2024
4 Comments (4 New)
New

While shapes are supported on Excel and PowerPoint Office.JS API, it's not the case of the Word API. Please allow us to:

 

  • Create a new shape
  • Edit the shape color and add a background image
  • Add text inside the shape
  • Set rounded corners (Especially for rectangles etc.)
  • Group and ungroup shapes

 

Thank you

Comments
Copper Contributor

I was amazed to see that this is not supported YET, when both PowerPoint and Excel support this feature. MS, plz make this a priority. Or if it is going to take time, plz provide a sample in ScriptLab on how to achieve this through OOXML.

Microsoft

@Dinosauro and @shujee Thanks for reporting this requirement. Can I know your user scenarios here?

Copper Contributor

In many of the JS add-ins that I was asked to build, users needed to interact with basic shapes (arrows, rects, ovals), change their properties (colors, pen style, fill), change their positions and sizes and virtually do a lot of stuff that is available in the UI. These actions can be done using VBA and VSTO too.

 

Same goes for non-inline pictures. One of my JS add-ins needs to manipulate picture positions and sizes and access the "Compress Picture" functionality.

 

Last but not the least, the same add-in needs to get the position of an INLINE image relative to the page. I'm not sure if that makes sense because this can't even be done in VSTO or VBA (obviously because it's an inline element), but I'm still looking for a possible way of achieving this, because the add-in needs to inject a Rectangle shape at the center of selected INLINE image.

Copper Contributor

Thank you for the response. In lots of documents, shapes are used for styling purposes: users can put rectangles colored in red and write inside them important information that immediately sticks in the mind, or they can put a picture in a circle shape so that it better fits the document style (for example in lots of CV templates a circular image is used). I think that lots of processes using shapes can be automated: filling the shape space with a picture would permit to create documents with more complex styles.

For example

  • The user can fill some fields about their occupatiom in the UI and, with Office.JS, a Word document with their full CV will be created, with a circular picture of the person at the top and other shapes in the corners of the CV to make it better-looking
  • A plugin that does searches on a private image library could add the image directly on the document with rounded corners, and under that write the source. By adding multiple shapes, writing into one of them and grouping them it would be possible

These are things that currently can be done from the Word UI on both Windows and macOS, and I really hope it'll be possible to do that also programmatically using the Office.JS API. Also, for more complex shapes, the ability to group them would be really useful, so that the user doesn't risk to accidentally move only a part of the entire shape