S
scottw
Need help with vba code that worked in Word-2003 but fails in 2007.
We have reports that add annotated diagrams (using .wmf images and autoshape
marks placed according to data in the report)
To get this done (in 2003), my code opens a blank document, adds the diagram
and the shapes, then groups these and copies them back to a bookmark in the
report. This code fails however in word 2007, (seems the graphics
capabilities are reduced?)
The code block below illustrates the problem, or you can see it by hand if
you manually add a small wmf file to a document then add an autoshape and try
to group them.
In 2003 you can simply select both (by holding the shift key) but not in
2007 - it will only select one or the other.
An added note - In 2007 you can select a (manually placed) wmf and in the
right mouse menu select 'edit picture' at which point there is the capability
to manually group. However, I have been unable to achieve this from code
(and the option is actually grayed out when you right mouse click an image
that was placed with the code below!)
'---------
sub OKIn2003Not2007
Set ad = ActiveDocument
ad.Shapes.AddPicture "c:/diagram.wmf"
ad.Shapes.AddShape Type:=msoShape5pointStar, _
Left:=82.3, Top:=98, _
Width:=18, Height:=18
ad.Shapes.SelectAll ' This fails in 2007 -
ad.Range.ShapeRange.Group.Select ' This is what i am trying to get done
Selection.Cut
' Then I do inline paste of shape group to a bookmark
End sub
'-------
Thanks in advance for any answers.
Scott Wiley
We have reports that add annotated diagrams (using .wmf images and autoshape
marks placed according to data in the report)
To get this done (in 2003), my code opens a blank document, adds the diagram
and the shapes, then groups these and copies them back to a bookmark in the
report. This code fails however in word 2007, (seems the graphics
capabilities are reduced?)
The code block below illustrates the problem, or you can see it by hand if
you manually add a small wmf file to a document then add an autoshape and try
to group them.
In 2003 you can simply select both (by holding the shift key) but not in
2007 - it will only select one or the other.
An added note - In 2007 you can select a (manually placed) wmf and in the
right mouse menu select 'edit picture' at which point there is the capability
to manually group. However, I have been unable to achieve this from code
(and the option is actually grayed out when you right mouse click an image
that was placed with the code below!)
'---------
sub OKIn2003Not2007
Set ad = ActiveDocument
ad.Shapes.AddPicture "c:/diagram.wmf"
ad.Shapes.AddShape Type:=msoShape5pointStar, _
Left:=82.3, Top:=98, _
Width:=18, Height:=18
ad.Shapes.SelectAll ' This fails in 2007 -
ad.Range.ShapeRange.Group.Select ' This is what i am trying to get done
Selection.Cut
' Then I do inline paste of shape group to a bookmark
End sub
'-------
Thanks in advance for any answers.
Scott Wiley