Ich bin neu hier und habe folgendes Problem:
Ich habe untenstehendes Makro soweit zum Laufen gebracht. Es funktioniert super. Nur wenn ich _ es ein zweites oder drittes mal starte fügt es die Bilder nicht mehr an der vorgegebenen Stelle ein, sondern an der Stelle die aktiviert wurde. Außerdem sind die Bilder nicht mehr der Zellengröße angepasst und sie sind alle übereinander angeordnet. Kann mir hier wer weiterhelfen? Vielen Dank!!!
Sub Bilder_einfügen()
Dim Rw&, PFAD$, Datei$, Bild As Shape
PFAD = "D:\Bilder\"
With ActiveSheet
Datei = .Range("C12") & ".jpg"
If Dir(PFAD & Datei) vbNullString Then
.Pictures.Insert (PFAD & Datei)
Set Bild = .Shapes(.Shapes.Count)
Bild.LockAspectRatio = msoFalse
Bild.Left = .Range("K12").Left
Bild.Top = .Range("K12").Top
Bild.Width = .Range("K12:K13").Width
Bild.Height = .Range("K12:K14").Height
End If
Datei = .Range("C17") & ".jpg"
If Dir(PFAD & Datei) vbNullString Then
.Pictures.Insert (PFAD & Datei)
Set Bild = .Shapes(.Shapes.Count)
Bild.LockAspectRatio = msoFalse
Bild.Left = .Range("K17").Left
Bild.Top = .Range("K17").Top
Bild.Width = .Range("K17").Width
Bild.Height = .Range("K17:K19").Height
End If
Datei = .Range("C22") & ".jpg"
If Dir(PFAD & Datei) vbNullString Then
.Pictures.Insert (PFAD & Datei)
Set Bild = .Shapes(.Shapes.Count)
Bild.LockAspectRatio = msoFalse
Bild.Left = .Range("K22").Left
Bild.Top = .Range("K22").Top
Bild.Width = .Range("K22").Width
Bild.Height = .Range("K22:K24").Height
End If
Datei = .Range("C27") & ".jpg"
If Dir(PFAD & Datei) vbNullString Then
.Pictures.Insert (PFAD & Datei)
Set Bild = .Shapes(.Shapes.Count)
Bild.LockAspectRatio = msoFalse
Bild.Left = .Range("K27").Left
Bild.Top = .Range("K27").Top
Bild.Width = .Range("K27").Width
Bild.Height = .Range("K27:K29").Height
End If
Datei = .Range("C32") & ".jpg"
If Dir(PFAD & Datei) vbNullString Then
.Pictures.Insert (PFAD & Datei)
Set Bild = .Shapes(.Shapes.Count)
Bild.LockAspectRatio = msoFalse
Bild.Left = .Range("K32").Left
Bild.Top = .Range("K32").Top
Bild.Width = .Range("K32").Width
Bild.Height = .Range("K32:K34").Height
End If
Datei = .Range("C37") & ".jpg"
If Dir(PFAD & Datei) vbNullString Then
.Pictures.Insert (PFAD & Datei)
Set Bild = .Shapes(.Shapes.Count)
Bild.LockAspectRatio = msoFalse
Bild.Left = .Range("K37").Left
Bild.Top = .Range("K37").Top
Bild.Width = .Range("K37").Width
Bild.Height = .Range("K37:K39").Height
End If
Datei = .Range("C42") & ".jpg"
If Dir(PFAD & Datei) vbNullString Then
.Pictures.Insert (PFAD & Datei)
Set Bild = .Shapes(.Shapes.Count)
Bild.LockAspectRatio = msoFalse
Bild.Left = .Range("K42").Left
Bild.Top = .Range("K42").Top
Bild.Width = .Range("K42").Width
Bild.Height = .Range("K42:K44").Height
End If
Datei = .Range("C47") & ".jpg"
If Dir(PFAD & Datei) vbNullString Then
.Pictures.Insert (PFAD & Datei)
Set Bild = .Shapes(.Shapes.Count)
Bild.LockAspectRatio = msoFalse
Bild.Left = .Range("K47").Left
Bild.Top = .Range("K47").Top
Bild.Width = .Range("K47").Width
Bild.Height = .Range("K47:K49").Height
End If
Datei = .Range("C52") & ".jpg"
If Dir(PFAD & Datei) vbNullString Then
.Pictures.Insert (PFAD & Datei)
Set Bild = .Shapes(.Shapes.Count)
Bild.LockAspectRatio = msoFalse
Bild.Left = .Range("K52").Left
Bild.Top = .Range("K52").Top
Bild.Width = .Range("K52").Width
Bild.Height = .Range("K52:K54").Height
End If
Datei = .Range("C57") & ".jpg"
If Dir(PFAD & Datei) vbNullString Then
.Pictures.Insert (PFAD & Datei)
Set Bild = .Shapes(.Shapes.Count)
Bild.LockAspectRatio = msoFalse
Bild.Left = .Range("K57").Left
Bild.Top = .Range("K57").Top
Bild.Width = .Range("K57").Width
Bild.Height = .Range("K57:K59").Height
End If
Datei = .Range("C62") & ".jpg"
If Dir(PFAD & Datei) vbNullString Then
.Pictures.Insert (PFAD & Datei)
Set Bild = .Shapes(.Shapes.Count)
Bild.LockAspectRatio = msoFalse
Bild.Left = .Range("K62").Left
Bild.Top = .Range("K62").Top
Bild.Width = .Range("K62").Width
Bild.Height = .Range("K62:K64").Height
End If
Datei = .Range("C67") & ".jpg"
If Dir(PFAD & Datei) vbNullString Then
.Pictures.Insert (PFAD & Datei)
Set Bild = .Shapes(.Shapes.Count)
Bild.LockAspectRatio = msoFalse
Bild.Left = .Range("K67").Left
Bild.Top = .Range("K67").Top
Bild.Width = .Range("K67").Width
Bild.Height = .Range("K67:K69").Height
End If
End With
End Sub