VBA for Images Location

naresh_ank

New Member
Joined
Nov 20, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hello Forum Group,
Grettingss...

Iam using below code to insert the Images in the Excel sheet ...

NewFN = "C:\Users\ankat\OneDrive\Pictures\Screen-Shots\Testcase1.jpg"
ActiveSheet.Shapes.AddPicture(Filename:=NewFN, _
LinkToFile:=msoFalse, _
SaveWithDocument:=msoTrue, _
Left:=1, Top:=1, Width:=140, Height:=195).Select

Here myself facing difficuly to insert the Image at Exact cell location,iam using Left and Top corredinates but if any body changes cell high then the corredinates are chageing and image is moving to other areas...

My self used "Range("A86").Select" , "ActiveCell.Select " but iam unable place the Image at this cell...

Please suggest the method to insert the Image @ cell loaction in the Excel sheet

Thanks





Please suggest how i can use
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Hi & welcome to MrExcel.
How about
VBA Code:
NewFN = "C:\Users\ankat\OneDrive\Pictures\Screen-Shots\Testcase1.jpg"
With Range("A86")
   ActiveSheet.Shapes.AddPicture(FileName:=NewFN, _
   LinkToFile:=msoFalse, _
   SaveWithDocument:=msoTrue, _
   Left:=.Left, Top:=.Top, Width:=140, Height:=195).Select
End With
 
Upvote 0
VBA Code:
Option Explicit

Sub Picture()

Range("F6").Select 'This is where picture will be inserted

ActiveSheet.Pictures.Insert("C:\Users\jimga\Desktop\stamp.png").Select
'Path to where pictures are stored - Edit as required

'''''''''''''''''''''''''''''''''''''''''''''''''''''''
' This resizes the picture
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
Application.ScreenUpdating = False

With Selection
.Left = Range("F6").Left                '<--- change cell as required
.Top = Range("f6").Top                  '<--- change cell as required
.ShapeRange.LockAspectRatio = msoFalse
.ShapeRange.Height = 100#
.ShapeRange.Width = 100#
.ShapeRange.Rotation = 0#
End With

Application.ScreenUpdating = True

Exit Sub

ErrNoPhoto:
MsgBox "Unable to Find Photo" 'Shows message box if picture not found
Exit Sub


End Sub
 
Upvote 0

Forum statistics

Threads
1,214,622
Messages
6,120,576
Members
448,972
Latest member
Shantanu2024

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