Hi all,
Hoping somebody can help.
This is my first time using VBA in a project & I'm not very familiar with it so I will need things explaining in a little more detail.
I have the below subs - Sub 1 is to use a button to select an image & to insert the file path into the table. The sub 2 should then display the image in a selected cell (M8). I keep getting the above error, at first I only had the problem when the workbook was protected, so I have added a work around. Since then I cannot select a cell containing a file path without getting the error. When selecting debug, it takes me to the line highlighted in red.
Any idea's on how I can fix this.
Sub 1:
Sub Cont_Attachthum()
Dim PicFile As FileDialog
With Sheet1
Set PicFile = Application.FileDialog(msoFileDialogFilePicker)
With PicFile
.Title = "Select a Contact Picture"
.Filters.Add "All Picture Files", ".jpg,*jpeg,*.gif,*.png,*bmp,*tiff", 1
If .Show <> -1 Then GoTo NoSelection
Sheet1.Range("Q11").Value = .SelectedItems(1) 'Put file name in Q11
End With
If .Range("B10").Value = False Then .Range("N" & Sheet1.Range("B9").Value).Value = .Range("Q11").Value
Cont_DisplayThumb
NoSelection:
End With
End Sub
Sub 2:
Sub Cont_DisplayThumb()
Dim PicPath As String
With Sheet1
On Error Resume Next
ActiveSheet.Protect Contents:=False
.Shapes("ThumbPic").Delete 'Delete thumbnail pic if any
On Error GoTo 0
PicPath = .Range("Q11").Value 'Picture Path
With .Pictures.Insert(PicPath)
With .ShapeRange
.LockAspectRatio = msoTrue
.Height = 80
.Name = "ThumbPic"
End With
End With
With .Shapes("ThumbPic")
.Left = Sheet1.Range("M8").Left
.Top = Sheet1.Range("M8").Top
.IncrementTop -35
End With
ActiveSheet.Protect Contents:=True
End With 'End Sheet1
End Sub
Hoping somebody can help.
This is my first time using VBA in a project & I'm not very familiar with it so I will need things explaining in a little more detail.
I have the below subs - Sub 1 is to use a button to select an image & to insert the file path into the table. The sub 2 should then display the image in a selected cell (M8). I keep getting the above error, at first I only had the problem when the workbook was protected, so I have added a work around. Since then I cannot select a cell containing a file path without getting the error. When selecting debug, it takes me to the line highlighted in red.
Any idea's on how I can fix this.
Sub 1:
Sub Cont_Attachthum()
Dim PicFile As FileDialog
With Sheet1
Set PicFile = Application.FileDialog(msoFileDialogFilePicker)
With PicFile
.Title = "Select a Contact Picture"
.Filters.Add "All Picture Files", ".jpg,*jpeg,*.gif,*.png,*bmp,*tiff", 1
If .Show <> -1 Then GoTo NoSelection
Sheet1.Range("Q11").Value = .SelectedItems(1) 'Put file name in Q11
End With
If .Range("B10").Value = False Then .Range("N" & Sheet1.Range("B9").Value).Value = .Range("Q11").Value
Cont_DisplayThumb
NoSelection:
End With
End Sub
Sub 2:
Sub Cont_DisplayThumb()
Dim PicPath As String
With Sheet1
On Error Resume Next
ActiveSheet.Protect Contents:=False
.Shapes("ThumbPic").Delete 'Delete thumbnail pic if any
On Error GoTo 0
PicPath = .Range("Q11").Value 'Picture Path
With .Pictures.Insert(PicPath)
With .ShapeRange
.LockAspectRatio = msoTrue
.Height = 80
.Name = "ThumbPic"
End With
End With
With .Shapes("ThumbPic")
.Left = Sheet1.Range("M8").Left
.Top = Sheet1.Range("M8").Top
.IncrementTop -35
End With
ActiveSheet.Protect Contents:=True
End With 'End Sheet1
End Sub