insert an image to defined position

jefflee

Board Regular
Joined
Jun 8, 2015
Messages
80
Sub draw1()




Dim picname As String

picname = Range("ao3")


ActiveSheet.Pictures.Insert("F:\Primary BK\photo\" & picname).Select

Selection.Name = "clo1"

Selection.ShapeRange.PictureFormat.TransparentBackground = msoTrue
Selection.ShapeRange.PictureFormat.TransparencyColor = RGB(255, 255, 255)
Selection.ShapeRange.Fill.Visible = msoFalse

end sub

I wrote to insert an image to the sheet as above

I want to insert it into designated position.

the position is in the value of a1 and a2..is it possible ?


ie.

the 12 , 32 is the position of the shape .

ActiveSheet.Shapes.AddShape(msoShapeRectangle, 12, 32, 70#, 70#). _
Select



please advise.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Try something like this, maybe.

On the sheet in F1 & F2 use - (minus) values for LEFT and UP, + (plus) for RIGHT and DOWN.

Howard


Code:
Option Explicit

Sub ShapesChaser()

Dim iLeft As Long
Dim iTop As Long

If Range("F1") = "**" Then Exit Sub

iLeft = Range("F1")
iTop = Range("F2")

    'Shapes(mso6-Point Star 2, 54, 13.5, 55.5, 15.75)
    
    ActiveSheet.Shapes.Range(Array("6-Point Star 2")).Select
    MsgBox iLeft & " " & iTop
    
    Selection.ShapeRange.IncrementLeft iLeft
    Selection.ShapeRange.IncrementTop iTop
    
[A1].Activate
[F1:F2] = "**"
End Sub
 
Upvote 0
Hi, Howard,
Thanks a lot your helping .
the macro works smoothly but I think my requirement is not clearly express

request as follow :

insert the image clo1 into the defined position

(indeed I've got many clo named clo1 , clo2 )
and I want to insert them to
x:50 y :50 for clo1
x:100 y :100 for clo2 and etc

where 50 50 is in cell a1 , a2 and 100 100 in cell b1 , b2

i am still working on it . thanks thanks
 
Upvote 0
Try
Code:
ActiveSheet.Pictures.Insert("F:\Primary BK\photo\" & picname).Select
Selection.Name = "clo1"
Selection.Top = 12
Selection.Left = 32
'etc.
 
Upvote 0
Hi, Mike,
Let me reply you with the most wonderful 7 alphabets ........."Ït works"!!!!!!!!!!!!!!!! , and I just make minor modification to insert the value in cell a1 and a2.
Thanks very very much
Best regards,
Iaudio1233
 
Upvote 0

Forum statistics

Threads
1,214,942
Messages
6,122,366
Members
449,080
Latest member
Armadillos

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