Hi Kate
When you use
LinkToFile:=False, SaveWithDocument:=True
.Shapes(.Shapes.Count).Ungroup
you ungroup the picture you just inserted. This
ungrouping generates new shapes and add to the shape
collection, or so you would think. Actually, if you
insert a WMF file and then ungroup it, the result is not
a bunch of new shapes, but a bunch of autoshapes, and the
TransparentBackground property does not apply to an
autoshape (you have to set the fillcolor to tranparant).
And you cannot ungropup a JPG...
Anyway, even if it worked, when you use
With .Shapes(.Shapes.Count)
right after ungrouping, you would have no idea which
shape from the group you are selecting (.Shape.Count
would represent the total number of shapes, and after
ungrouping, which one (From the group) is the last (or
highest) number?).
So the question is: Why do you ungroup?
If it is to set the background to transparent, then, and
only if it is a simple picture, do not ungroup it and try
using
BlueScreen = RGB(255, 255, 255).
I tried it with simple BMP, JPG and WMF pictures, and it
worked. But often pictures, especially WMF pictures from
the Office Clip Art library, are drawn with a bunch of
superposed pictures, so there is no real "Background" to
speak of...
Finally, you cannot record your action if you click about
the screen with the mouse when you try to select
pictures. You have to find ways to do your actions
through the keyboard, which can be difficult when dealing
with picture because you cannot navigate through the
pictures in a document with the keyboard. So, you have to
select the shape you want, then run the macro recorder,
use the keyboard and then modify the result in the VBA
editor window... To deal with shapes you have to know
either their index number in the shape collection, or
their individual names.
What I have done in the past is use AutoText to store
pictures I wanted the user to use, and I gave them names
before (by using VBA and the Name property), so I could
control the selection from the code by using their names,
and checking for errors if the name was not found in the
document, meaning the picture is not there...
HTH
Cheers!