As you can see, I stuck in a couple msgboxes near the end to tell me the shape names. The return the expected names. What is most maddening is that I can run this test macro and it does exactly what I want:
Sub captionselectedphoto(control As IRibbonControl) Dim shapesselected As Integer Dim photos2caption As ShapeRange Dim phototitle As String shapesselected = Selection.ShapeRange.count If shapesselected = 0 Then MsgBox "Please select one or more photos to caption, then try again" Exit Sub End If Set photos2caption = Selection.ShapeRange If photos2caption.count > 1 Then photos2caption.Group Application.ScreenRefresh phototitle = InputBox("Photo title?") Selection.InsertCaption Label:="Figure", TitleAutoText:="", _ Title:=": " & phototitle, Position:=wdCaptionPositionBelow, ExcludeLabel:=0 Set captionbox = ActiveDocument.Shapes(ActiveDocument.Shapes.count) MsgBox photos2caption.Name 'returns "Group 20" MsgBox captionbox.Name 'returns "Text Box 9" ActiveDocument.Shapes.Range(Array(photos2caption.Name, captionbox.Name)).Group End Sub
This is what I'm aiming for. Is there something wrong with my syntax? Can I not put variables in the array statement like this? What am I doing wrong?
ActiveDocument.Shapes.Range(Array("Group 20", "Text Box 9")).Group
Do more with