Hi This first bit of code will insert all you pictures on the sheet.
It will also Places there Names (These will be names like "Picture 1" -Excel gives them these names) in column "A" starting in row 2.
You will have to alter the file path and extension to suit.
If you dont want to do this you will have to insert them (and there new names) all individually, and that could take some time.
The second Bit of code will Insert them on the sheet.
The code must be run from a "Selectionchange" event.
When you Select a name from Column "A" that picture will become "Visible"
When you Select another name the first Picture is "Hidden" and the new Pictures Shows.
You will see in the code some details about size and range position, that you can alter to suit.
Place on you sheet, somewhere suitable the words "Picture Delete" ( No Commas)
When you select "Picture Delete" any Pictures on the page will be Hidden.
Place Picture on Sheet from File :- Code
Code:
Dim myDir As String, fn As String
Dim Fpth As String, c As Integer
myDir = "C:\Documents and Settings\test\My Documents\My Pictures"
fn = Dir(myDir & "\*.jpg")
c = 1
Do While fn <> ""
Fpth = myDir & "\" & fn
ActiveSheet.Pictures.Insert(Fpth).Select
With Selection
.Height = 50
.Width = 100
.Top = Range("c1").Top
.Left = Range("c1").Left
c = c + 1
Cells(c, 1) = Selection.name
End With
fn = Dir
Loop
Select Picture (Visible) on sheet:-Code.
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim oPic As shape, allpic As String, Pic As String
Dim oP As String, c As Integer
Application.ScreenUpdating = False
If Target.Value = "" Then Exit Sub
If Target.Value <> "" Then
If split(Target.Value, " ")(0) = "Picture" Then
Me.Pictures.Visible = True
For Each oPic In Me.Shapes
If oPic.Type = 13 Then
oPic.Visible = False
End If
Next oPic
If Not Target.Value = "Picture Delete" Then
Pic = Target.Value
ActiveSheet.Shapes(Pic).Visible = True
With ActiveSheet.Shapes(Pic)
.Height = 200
.Width = 300
.Top = Range("b1").Top
.Left = Range("b1").Left
End With
End If
End If
End If
Application.ScreenUpdating = True
End Sub
Have a Go
Good Luck
Mick