Change Picture

B

B Lynn B

After using the 2007 ribbon menus to insert a picture on my sheet, I can
right click the picture and get an option to "change picture". But macro
recorder doesn't capture this, and I've had a hard time finding the answer in
the object model reference. What is the code equivalent of "change picture"?
Please and thanks!
 
J

Javed

After using the 2007 ribbon menus to insert a picture on my sheet, I can
right click the picture and get an option to "change picture".  But macro
recorder doesn't capture this, and I've had a hard time finding the answer in
the object model reference.  What is the code equivalent of "change picture"?
 Please and thanks!

You can use following:

Worksheets("Sheetname").Pictures.Insert "Filename"

Don't ask me why the pictures object not in Object model of Sheet
object.Ask MS.
 
B

B Lynn B

Thanks Javed. Appreciate the effort to help. The code below adds a new
picture, so there are then two. I already have it solved that way - while
first deleting the one already there. I was hoping to change the image of an
existing picture.

And I agree, as I looked for a way to "speak" to the existing picture
object, I had a hard time believing it simply didn't exist in the object
model.
 
P

Peter T

I had a hard time believing it simply didn't exist in the object

Me too!
As you say the only way appears to insert a new picture. What you could do
is start by extracting all the properties from the original Picture, in
particular it's dimensions, order-position and name. Insert the new picture
then assign all similar properties including its name (after deleting the
original picture of course).

Regards,
Peter T
 
B

B Lynn B

Thanks Peter - it's helpful just to have confirmation that I should stop
looking for the answer and chalk it up to application builders' oversight. I
can live with that more easily than fretting over the possibility I've just
failed to find the right solution. :)
 

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