A text box in excel that contains a Picture taken from a file
How can I create a text box in excel that contains a Picture taken from a specific folder ?
My folder is @ "C:\PeopleFolder\"
I want to create an InputBox on a worksheet so that when I enter a name, it looks up the image name and inserts the corresponding image into a cell if it exists.
I'll link a TextBox on the worksheet to that cell to display the image.
How is this doable ?
VBA or Worksheet solution; Doesn't matter.
Re:: A text box in excel that contains a Picture taken from a file
use this
Code:
Sub Picture()Dim picname As String
Range("B1").Select 'This is where picture will be inserted
picname = Range("A1") 'This is the picture name
On Error Resume Next
'delete previous pic
ActiveSheet.Pictures("ProfilePicture").Delete
Err.Clear
Err.Number = 0
On Error GoTo 0
If (Dir("C:\Users\JINOOB\Desktop\I A\" & picname & ".jpg") = vbNullString) Then Exit Sub
ActiveSheet.Pictures.Insert("C:\Users\JINOOB\Desktop\I A\" & picname & ".jpg").Select 'Path to where pictures are stored
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
' This resizes the picture
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
With Selection
.Name = "ProfilePicture"
.Left = Range("B1").Left
.Top = Range("B1").Top
.ShapeRange.LockAspectRatio = msoFalse
.ShapeRange.Height = 95#
.ShapeRange.Width = 80#
.ShapeRange.Rotation = 0#
End With
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If (Intersect(Target, Range("A1")) Is Nothing) Then
Exit Sub End If