Input Box /Insert Picture
22.09.2017 17:03:20
Jonas
Ich würde einen Bereich mit der Inputbox auswählen, in welcher Produktnummern stehen und dann einen Bereich auswählen, wo sie automatisch eingefügt werden.
Leider komme ich nicht weiter, da eine Range kein Value haben kann.
Könnte mir jemand bitte helfen?
Sub insert_picture()
Dim strpath As String
Dim rng2 As Range
Dim rng1 As Range
strpath = "C:\Bilder\"
Set rng1 = Application.InputBox _
(Prompt:="Enter the range or use the mouse", Type:=8)
Set rng2 = Application.InputBox _
(Prompt:="Enter the range where the pictures should be inserted", Type:=8)
If ActiveSheet.Range(rng2).Value > 0 Then
On Error Resume Next
ActiveSheet(rng1).Select
Set Zelle = ActiveCell
If Not Dir(strpath & Range(rng2).Value & ".JPG") = "" Then
Set bild = ActiveSheet.Pictures.insert(strpath & Range(rng2).Value ".JPG")
With bild
.Placement = 2
.Left = Zelle.Left
.Top = Zelle.Top
.Width = Zelle.Height
.Height = Zelle.Height
End With
End If
End If
Next
End Sub