Excel vba Shapes.addshapes

wahmed

Board Regular
Joined
Jun 28, 2010
Messages
66
Dear Fellows.

I have a sheet inwhich I am inserting pictures through getopenfilename Method but I am having problem for inserting picture next time on same sheet, I wish that when I insert a picture in a sheet next time second picture inserted two rows below first picture.

and then third picture below two rows of second picture.

your help in this regard would be highly appreciated.

Thanking you.

Wahmed
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Hi Wahmed,

In order to modify your code to put each successive picture two rows below the previous we would need to see the code you are using now. Could you post it?

Damon
 
Upvote 0
Dear Damon,

Here is the code I am using for inserting first picture at G10 range but dont know how to insert second picture two rows below it ,third picture two rows below second picture and so on..

Sub INSERTINGPICTURE()

'for inserting picture and not saving picture with workbook for saving space

Dim ws As Worksheet
Set ws = ActiveSheet

MYPICT = Application.GetOpenFilename


lef = Range("G10").Left
tp = Range("G10").Top


With ws.Shapes.AddPicture(MYPICT, True, False, lef, tp, 200, 200)
End With


End Sub
 
Upvote 0
Give this modification to your code a try...
Code:
Sub INSERTINGPICTURE()
  'for inserting picture and not saving picture with workbook for saving space
  Dim ws As Worksheet, MYPICT As String, tp As Double, lef As Double
  Set ws = ActiveSheet
  
  MYPICT = Application.GetOpenFilename
  
  lef = Range("G10").Left
  If ws.Shapes.Count = 0 Then
    tp = Range("G10").Top
  Else
    tp = ws.Shapes(ws.Shapes.Count).BottomRightCell.Offset(2).Top
  End If
  
  ws.Shapes.AddPicture MYPICT, True, False, lef, tp, 200, 200
End Sub
 
Upvote 0
Dear Rick,

Thanks for your help in this regard, Really thankful to you because it worked same as desired...

Thank you so much...

Regards

Wahmed
 
Upvote 0
Dear Rick,

Could you help me more by giving more Guidance to make hyperlink on each image inserting as shapes.addshape method ?

I mean when I insert a picture then I would like to have it hyperlinked with particular sheet,,, but dont want to do manually. is it possible ?

regards

Wahmed
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,730
Members
452,939
Latest member
WCrawford

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