Insert pictures with height & position

noelmus
NewLounger
Posts: 12
Joined: 12 Sep 2020, 15:08

Insert pictures with height & position

Post by noelmus »

Hi
I used this code (below) to insert a picture for an active sheet. I have a folder with 17 workbooks where each workbook is identical.
Is it possible to modify this code to insert a picture in only 3 sheets named "P1", "P2" and "P3" (which are protected) of each workbook in this folder?
Thanks.

Code: Select all

Sub InsertPicture()

Dim AddresPath As String
  
AddresPath = "C:\Users\mike\Pictures\cat.jpg"
  
Set myPicture = ActiveSheet.Pictures.Insert(AddresPath)
  
'Set the location, width and height
With myPicture
    .ShapeRange.LockAspectRatio = msoTrue
    .Height = 60
    .Top = Rows(1).Top
    .Left = Columns(1).Left
End With
End Sub

User avatar
HansV
Administrator
Posts: 78237
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Insert pictures with height & position

Post by HansV »

This is very similar to your previous question, you should be able to adapt the code for this one.
Best wishes,
Hans