PDA

View Full Version : Use VBA to group shapes in WORD on Mac



Yonz
12-30-2017, 02:44 PM
Hi all,

I'm trying to group two shapes (an image and its caption) in VBA on a Mac (Mac OS 10.13.2, Word 15.41)

to test: Create an empty document, add an image (Normale shape, not inline) and a text box


Sub GroupTwoBoxes()


ActiveDocument.Shapes.Range(Array(ActiveDocument.Shapes(1).Name, ActiveDocument.Shapes(2).Name)).Select
Selection.ShapeRange.Group


End Sub


When I run this script I get "runtime Error 9" The element with the given name does not exists.

running the exact same code on Windows works as expected (also Word 15.41)

Any Idea?

or is this just another case of: "If it looks like a bug and quacks like a bug, chances are this is a bug"

BR
Yonz

Yonz
01-13-2018, 07:34 AM
Hi all,

There are many issues with the "old" object model (version 14.***) used by word for MAC. Microsoft have fixed this, and with the latest release (16.9, available [Jan 2018] via the Office Insider Program).

Using the 16.9 Version of WORD on Mac most issues I had encountered are solved:
1: Group Shapes
2: Access to additional Properties, such as "AltText" and "Title"
3: Assign a new name to a Shape

One issue remains: When you copy / paste a shape (e.g. a picture) the name of the shape is copied as well. This implies that the <<Shape>>.name property is NOT unique, making it impossible to use the activedocument.shapes.range method to create a shaperange object, as it will fail with two duplicate objects in document.