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
8 Comments
Sort By
- Yun_Wang
Microsoft
We started to support Shape via the following requirement set which is for Windows and Mac:
- shujeeCopper Contributor
Just how many more years will the Office.js team require to address this? This request has been posted so many times before too. They left VSTO in the dirt and convinced everyone to move to JS and here we are after 10+ years of library development.
- Yun_Wang
Microsoft
We are working on this, and Shape APIs will be delivered by stages in the coming months. We will update this entry when the first set of Shape APIs are available. Thanks.
- ChrudCopper Contributor
Shapes are also useful in creating book covers for on-demand book printers. Being able to create shapes and size/position them on a page (and in groups?) makes it possible to support multiple cover types (softback, hardback, different publishers, different spine widths) from one document. This would require manipulating shape layout (position and size) as well as textbox layout and properties.
- DinosauroCopper 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
- shujeeCopper 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.
- Yun_Wang
Microsoft
- shujeeCopper 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.