Shapes Formulas

ExcelNewb09

Board Regular
Joined
Jan 1, 2009
Messages
84
I have a picture I want to change through VBA.

the following code works:
Code:
    ActiveSheet.Shapes("picTransfer").Select
    
    Selection.Formula = "SALS!Picture"

but this code doesn't

Code:
    ActiveSheet.Shapes("picTransfer").Formula = "SALS!Picture"

any ideas why?
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
I'm sure there are more technical explanations but suffice to say that the Shape is not a worksheet object. It's just an object planted on the sheet.

You have the option though to dismiss focus from the object (de-select it) by either selecting/setting focus to something else or using the line:
SendKeys "{ESC}"

Hope it helps.
 
Upvote 0
Hi

A shape does not have any Formula property.

You are using a shape as a container to an object. You must access the object inside the shape. You forgot to mentions what object you have.

For a drawing object try:

Code:
ActiveSheet.Shapes("picTransfer").DrawingObject.Formula = "SALS!Picture"

This is more general, will also work for other cases:

Code:
ActiveSheet.Shapes("picTransfer").OLEFormat.Object.Formula = "SALS!Picture"

Please try it and if it doesn't work post details: what object do you have, how you created it (for ex.: from the forms or from the controls toolbar), the code you wrote, etc.
 
Upvote 0
Formula is not a property of a Shape. So it cant be set. The first bit of coded errors for me.

What are you trying to achieve?
 
Upvote 0

Forum statistics

Threads
1,203,094
Messages
6,053,503
Members
444,667
Latest member
KWR21

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top