Compile error message 'Expected End Sub'

Taver

New Member
Joined
Jun 15, 2020
Messages
1
Office Version
  1. 2007
Platform
  1. Windows
Hello, I am new to VBA. I'm trying to use these code but a compile error message 'Expected End Sub' keeps poping up on first line of code.
I need your help please.

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 .ShapeRage
.LockAspectRatio = msoTrue
.Heihgt = 95
.Name = "EmplPic"
End With 'Shape Range
End With 'Pictures

With .Shapes("EmplPic")
.Left = Sheet1.Range("I5").Letf
.Top = Sheet1.Range("I5").Top
.IncreamentLeft 50
.IncreamentTop 15
End With
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Hi & welcome to MrExcel.
Just add
VBA Code:
End Sub
at the end of your code.
 
Upvote 0
Hi & welcome to MrExcel.
Just add
VBA Code:
End Sub
at the end of your code.
Hi I have the same code but this line always keep to how error message

.Shapes("DefaultPicture").Visible = msoFalse

it is automation error. please check
 

Attachments

  • automation error.PNG
    automation error.PNG
    33.5 KB · Views: 13
Upvote 0
As this has nothing to do with the original question, you will need to start a new thread.
 
Upvote 0

Forum statistics

Threads
1,214,947
Messages
6,122,413
Members
449,082
Latest member
tish101

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