View Full Version : How to give another name to a Group using PowerPoint VBA?
JariV
02-05-2012, 08:28 AM
Hi
is it possible to give a descriptive name to a Group of Shapes after I have grouped them with the command :
ActiveWindow.Selection.ShapeRange.Group
I know it is possible manually by using the Selection Pane, but I'd like to do it with a code, and I also would like to access the Group later by using the name, much like it is possible to give Shapes names and use the names as a reference in the code.
Thanks,
-Jari V
John Wilson
02-05-2012, 11:58 AM
here's two ways:
With ActiveWindow.Selection.ShapeRange.Group
.Name = "Thisismygroup"
End With
Dim ogrp As Object
Set ogrp = ActiveWindow.Selection.ShapeRange.Group
ogrp.Name = "Thisismygroup2"
JariV
02-06-2012, 02:52 AM
Thanks John!
the second method worked well. With the first one I had some problems with my code as it appears that the selection is automativally unselected after the .Group command and error resulted. The same method worked though with a simple trial code.
Do not know what's the bug in my code.
But anyways I can use the second method.
Regards,
-Jari V
John Wilson
02-06-2012, 07:01 AM
You could say:
With ActiveWindow.Selection.ShapeRange.Group
.Name = "Thisismygroup"
.Select
End With
But personally I always try to avoid working with selected shapes. If you post more of what you are doing I'll see if i can help you avoid this.
JariV
02-07-2012, 10:36 AM
Thanks John,
but I already deleted the code which did not appear to work.
This example works fine:
========
Sub TestSelect()
Dim X As Integer
Dim oShape As Shape
For X = 1 To ActivePresentation.Slides(2).Shapes.Count
Set oShape = ActivePresentation.Slides(2).Shapes(X)
With oShape
.Select (msoFalse)
End With
Next
With ActiveWindow.Selection.ShapeRange.Group
.Name = "MyGroup"
End With
End Sub
========
I do not know what was the problem, maybe I missed something trivial.
JariV
John Wilson
02-07-2012, 11:00 AM
You can group all shapes on a slide
ActivePresentation.Slides(1).Shapes.Range.Group.Select
One problem in both methods is some shapes cannot be grouped. (Placeholders especially)
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.