Copying correct vba codes from youtube then having error in my excel

sanc0012

New Member
Joined
Dec 21, 2020
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hi, I am having this error where I see it run in youtube but when I try it in my excel it gets automation error. What seems to be the problem? The color blue is the one getting error

Rich (BB code):
Sub Show_EmplPic()
Dim PicPath As String
With Sheet1
On Error Resume Next
.Shapes("EmplPic").Delete 'Delete Picture if it Exists
On Error GoTo 0
PicPath = .Range("J10").Value 'Path of the picture
If PicPath = Empty Then

.Shapes("DefaultPicture").Visible = msoCTrue
Exit Sub

End If
.Shapes("DefaultPicture").Visible = msoFalse
With .Pictures.Insert(PicPath)
With .ShapeRange
   .LockAspectRatio = msoTrue
    .Height = 97
    .Name = "EmplPic"
    End With 'Shape Range
End With 'Pictures
With .Shapes("EmplPic")
.Left = Sheet1.Range("I5").Left
.Top = Sheet1.Range("I5").Top
.IncrementLeft 53
.IncrementTop 14


End With 'Sheet 1
   
End With
End Sub
 

Attachments

  • automation error.PNG
    automation error.PNG
    32.9 KB · Views: 14

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Do you have a shape with the name 'DefaultPicture' on the worksheet with the codename 'Sheet1'?
 
Upvote 0
Do you have a shape with the name 'DefaultPicture' on the worksheet with the codename 'Sheet1'?
I do not have. I checked the youtube video i'm using as tutorial and he do not have too.
 
Upvote 0

Forum statistics

Threads
1,214,636
Messages
6,120,669
Members
448,977
Latest member
moonlight6

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