I need to select multiple and specific shapes on a drawing canvas after they
have been drawn automatically with programming (using vba).

I have all the objects below defined in my code:

Dim myDoc As Document
Set myDoc = Application.ActiveDocument

Dim myCanvas As Shape

Set myCanvas = myDoc.Shapes(strCanvas) 'this is a variable supplied by
the

'argument in the procedure call
Dim shpCanvasShapes As CanvasShapes
Set shpCanvasShapes = myCanvas.CanvasItems

Dim myShape As Shape
Set myShape = shpCanvasShapes.AddTextbox (or AddAnyOtherShape...........)

After I've done this several times, I need to go back and "group" 5 shapes
that have been drawn on the canvas programmatically. Please point me in the
right direction to do this in Microsoft Word 2003.
--
Thanks!
Mona-ABE

RE: vba to select multiple shapes on a drawing canvas by oldman

oldman
Thu Apr 12 18:52:00 CDT 2007

Hi,

A canvas is just another shape in word. The objects are child objects in the
canvas - lets say the canvas is the first shape in the page then this will
select the first two drawing objects on the canvas (shapes that are not
inline shapes have names automatically assigned to them and after they are
created you can read the name and then reassign a meaningful name through
vba.)

ActiveDocument.Shapes(1).CanvasItems.Range(Array(1, 2)).Select

Set range1 = Selection.Range

This assumes the first shape in the document is a canvas and has at least
two ojects in it.
old man


"Mona-ABE" wrote:

> I need to select multiple and specific shapes on a drawing canvas after they
> have been drawn automatically with programming (using vba).
>
> I have all the objects below defined in my code:
>
> Dim myDoc As Document
> Set myDoc = Application.ActiveDocument
>
> Dim myCanvas As Shape
>
> Set myCanvas = myDoc.Shapes(strCanvas) 'this is a variable supplied by
> the
>
> 'argument in the procedure call
> Dim shpCanvasShapes As CanvasShapes
> Set shpCanvasShapes = myCanvas.CanvasItems
>
> Dim myShape As Shape
> Set myShape = shpCanvasShapes.AddTextbox (or AddAnyOtherShape...........)
>
> After I've done this several times, I need to go back and "group" 5 shapes
> that have been drawn on the canvas programmatically. Please point me in the
> right direction to do this in Microsoft Word 2003.
> --
> Thanks!
> Mona-ABE

RE: vba to select multiple shapes on a drawing canvas by MonaABE

MonaABE
Fri Apr 13 06:20:01 CDT 2007

You saved my life!

With your excellent explanation, I put this together and it's working
perfectly!

intSelTxtBx = shpCanvasShapes.Count

ActiveDocument.Shapes(strCanvas).CanvasItems.Range(Array(intSelTxtBx -
4, intSelTxtBx - 3, intSelTxtBx - 2, intSelTxtBx - 1, intSelTxtBx)).Group

I'm so thankful for this forum, and for contributors like you!
--
Take care,
Mona-ABE


"old man" wrote:

> Hi,
>
> A canvas is just another shape in word. The objects are child objects in the
> canvas - lets say the canvas is the first shape in the page then this will
> select the first two drawing objects on the canvas (shapes that are not
> inline shapes have names automatically assigned to them and after they are
> created you can read the name and then reassign a meaningful name through
> vba.)
>
> ActiveDocument.Shapes(1).CanvasItems.Range(Array(1, 2)).Select
>
> Set range1 = Selection.Range
>
> This assumes the first shape in the document is a canvas and has at least
> two ojects in it.
> old man
>
>
> "Mona-ABE" wrote:
>
> > I need to select multiple and specific shapes on a drawing canvas after they
> > have been drawn automatically with programming (using vba).
> >
> > I have all the objects below defined in my code:
> >
> > Dim myDoc As Document
> > Set myDoc = Application.ActiveDocument
> >
> > Dim myCanvas As Shape
> >
> > Set myCanvas = myDoc.Shapes(strCanvas) 'this is a variable supplied by
> > the
> >
> > 'argument in the procedure call
> > Dim shpCanvasShapes As CanvasShapes
> > Set shpCanvasShapes = myCanvas.CanvasItems
> >
> > Dim myShape As Shape
> > Set myShape = shpCanvasShapes.AddTextbox (or AddAnyOtherShape...........)
> >
> > After I've done this several times, I need to go back and "group" 5 shapes
> > that have been drawn on the canvas programmatically. Please point me in the
> > right direction to do this in Microsoft Word 2003.
> > --
> > Thanks!
> > Mona-ABE

RE: vba to select multiple shapes on a drawing canvas by oldman

oldman
Fri Apr 13 12:26:01 CDT 2007

Hi,

Thanks for your kind words. I don't see all the code but perhaps you want to
check if intSelTxtBx has a value of 4 or more before you select the shapes.

old man

"Mona-ABE" wrote:

> You saved my life!
>
> With your excellent explanation, I put this together and it's working
> perfectly!
>
> intSelTxtBx = shpCanvasShapes.Count
>
> ActiveDocument.Shapes(strCanvas).CanvasItems.Range(Array(intSelTxtBx -
> 4, intSelTxtBx - 3, intSelTxtBx - 2, intSelTxtBx - 1, intSelTxtBx)).Group
>
> I'm so thankful for this forum, and for contributors like you!
> --
> Take care,
> Mona-ABE
>
>
> "old man" wrote:
>
> > Hi,
> >
> > A canvas is just another shape in word. The objects are child objects in the
> > canvas - lets say the canvas is the first shape in the page then this will
> > select the first two drawing objects on the canvas (shapes that are not
> > inline shapes have names automatically assigned to them and after they are
> > created you can read the name and then reassign a meaningful name through
> > vba.)
> >
> > ActiveDocument.Shapes(1).CanvasItems.Range(Array(1, 2)).Select
> >
> > Set range1 = Selection.Range
> >
> > This assumes the first shape in the document is a canvas and has at least
> > two ojects in it.
> > old man
> >
> >
> > "Mona-ABE" wrote:
> >
> > > I need to select multiple and specific shapes on a drawing canvas after they
> > > have been drawn automatically with programming (using vba).
> > >
> > > I have all the objects below defined in my code:
> > >
> > > Dim myDoc As Document
> > > Set myDoc = Application.ActiveDocument
> > >
> > > Dim myCanvas As Shape
> > >
> > > Set myCanvas = myDoc.Shapes(strCanvas) 'this is a variable supplied by
> > > the
> > >
> > > 'argument in the procedure call
> > > Dim shpCanvasShapes As CanvasShapes
> > > Set shpCanvasShapes = myCanvas.CanvasItems
> > >
> > > Dim myShape As Shape
> > > Set myShape = shpCanvasShapes.AddTextbox (or AddAnyOtherShape...........)
> > >
> > > After I've done this several times, I need to go back and "group" 5 shapes
> > > that have been drawn on the canvas programmatically. Please point me in the
> > > right direction to do this in Microsoft Word 2003.
> > > --
> > > Thanks!
> > > Mona-ABE

RE: vba to select multiple shapes on a drawing canvas by MonaABE

MonaABE
Mon Apr 16 06:44:02 CDT 2007

That's an excellent point...I'll add that line of code.
if intSelTxtBx >= 4 then
...
end if

--
Thanks again!
Mona-ABE


"old man" wrote:

> Hi,
>
> Thanks for your kind words. I don't see all the code but perhaps you want to
> check if intSelTxtBx has a value of 4 or more before you select the shapes.
>
> old man
>
> "Mona-ABE" wrote:
>
> > You saved my life!
> >
> > With your excellent explanation, I put this together and it's working
> > perfectly!
> >
> > intSelTxtBx = shpCanvasShapes.Count
> >
> > ActiveDocument.Shapes(strCanvas).CanvasItems.Range(Array(intSelTxtBx -
> > 4, intSelTxtBx - 3, intSelTxtBx - 2, intSelTxtBx - 1, intSelTxtBx)).Group
> >
> > I'm so thankful for this forum, and for contributors like you!
> > --
> > Take care,
> > Mona-ABE
> >
> >
> > "old man" wrote:
> >
> > > Hi,
> > >
> > > A canvas is just another shape in word. The objects are child objects in the
> > > canvas - lets say the canvas is the first shape in the page then this will
> > > select the first two drawing objects on the canvas (shapes that are not
> > > inline shapes have names automatically assigned to them and after they are
> > > created you can read the name and then reassign a meaningful name through
> > > vba.)
> > >
> > > ActiveDocument.Shapes(1).CanvasItems.Range(Array(1, 2)).Select
> > >
> > > Set range1 = Selection.Range
> > >
> > > This assumes the first shape in the document is a canvas and has at least
> > > two ojects in it.
> > > old man
> > >
> > >
> > > "Mona-ABE" wrote:
> > >
> > > > I need to select multiple and specific shapes on a drawing canvas after they
> > > > have been drawn automatically with programming (using vba).
> > > >
> > > > I have all the objects below defined in my code:
> > > >
> > > > Dim myDoc As Document
> > > > Set myDoc = Application.ActiveDocument
> > > >
> > > > Dim myCanvas As Shape
> > > >
> > > > Set myCanvas = myDoc.Shapes(strCanvas) 'this is a variable supplied by
> > > > the
> > > >
> > > > 'argument in the procedure call
> > > > Dim shpCanvasShapes As CanvasShapes
> > > > Set shpCanvasShapes = myCanvas.CanvasItems
> > > >
> > > > Dim myShape As Shape
> > > > Set myShape = shpCanvasShapes.AddTextbox (or AddAnyOtherShape...........)
> > > >
> > > > After I've done this several times, I need to go back and "group" 5 shapes
> > > > that have been drawn on the canvas programmatically. Please point me in the
> > > > right direction to do this in Microsoft Word 2003.
> > > > --
> > > > Thanks!
> > > > Mona-ABE