Selecting part of an ungrouped shape

K

Kate Moncrieff

Hi,

I have a macro which inserts and ungroups a metafile
picture as follows:

With ActiveDocument
.Shapes.AddPicture FileName:=vrtSelectedItem,
LinkToFile:=False, SaveWithDocument:=True
.Shapes(.Shapes.Count).Ungroup
End With

The next thing I want to do is to select the part of the
ungrouped image that contains the background and change
the colour of it to "No fill". (To do this manually in
Word, I right-click on that part of the picture,
select "Format Autoshape" and change the Fill.Color value
on the "Colors and Lines" page.)

From the online help, it seems that what I need to do is
to select the appropriate (auto)shape that was generated
by the .UnGroup command and change the .Fill.Visible
property of it to msoFalse.

My problem is that, even after the ungrouping, vb doesn't
seem to recognize that the document now contains several
shapes instead of just the original one; the value of
ActiveDocument.Shapes.Count is still 1. (This is despite
the fact that the ungrouping has apparently worked and I
can select different parts of the image individually.)
Could anyone tell me how I can write code to select just a
part of the ungrouped image so that I can change the fill
colour? (In case it's relevant, I've noticed that when I
do what I need to do manually, the thing I have to click
on in order to get the "Format Autoshape" option doesn't
seem to be a fully-fledged shape; when selected, it's
surrounded by little circles, not a thick stripy line.)

Can anyone help?

Many thanks!
Kate

PS I did ask something similar before and got some
helpful answers. I thought I'd solved the problem but,
when I tried on a machine with Windows 2000, it still
didn't seem to work :(
 
C

Cindy Meister -WordMVP-

Hi Kate,
Could anyone tell me how I can write code to select just a
part of the ungrouped image so that I can change the fill
colour?
Does this code snippet help you get past the block?

Dim shp As Word.Shape, gshp As Word.Shape
Set shp = ActiveDocument.Shapes(1)
For Each gshp In shp.GroupItems
Debug.Print gshp.Name
Next gshp


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep
30 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top