Live-Forum - Die aktuellen Beiträge
Datum
Titel
24.04.2024 19:29:30
24.04.2024 18:49:56
Anzeige
Archiv - Navigation
1592to1596
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Bilder einfügen

Bilder einfügen
30.11.2017 06:38:21
Tippi
Guten Morgen Zusammen
Ich habe mal wieder ein Problem und zwar habe ich ein Code den ich schon mit eurer Hilfe erstellt habe der auch super läuft nur das wenn ich die Datei verschicke die Bilder alle weg sind.
Wie muss ich mein Code umstellen das die Bilder mit verschickt werden
Danke schon mal für eure Hilfe
Hier mein Code
Sub insertPicturesTest()
Dim objPic As Object
Dim lngRow As Long, lngLast As Long
Dim dblOHeight As Double, dblOWidth As Double
Dim strFile As String
Dim S
For Each S In ActiveSheet.Shapes
If Not Intersect(S.TopLeftCell, Range("F:F")) Is Nothing Then S.Delete
Next S
Const cstrPath As String = "R:\Logistik\" 'Pfad
Const cstrExtention As String = ".jpg"
With Sheets("Tabelle1") 'Tabellenname anpassen!
lngLast = Application.Max(1, .Cells(.Rows.Count, 2).End(xlUp).Row)
For lngRow = 11 To lngLast
If .Cells(lngRow, 2)  "" Then
strFile = Dir(cstrPath & IIf(Right(cstrPath, 1) = "\", "", "\") & .Cells(lngRow, 2) &  _
cstrExtention, vbNormal)
If strFile  "" Then
Set objPic = .Pictures.Insert(cstrPath & IIf(Right(cstrPath, 1) = "\", "", "\") &  _
strFile)
objPic.Top = .Cells(lngRow, 1).Top
objPic.Left = .Cells(lngRow, 6).Left
dblOHeight = 10
dblOWidth = 10
objPic.ShapeRange.LockAspectRatio = False
objPic.Height = .Cells(lngRow, 2).Height
objPic.Width = dblOWidth * (objPic.Height / dblOHeight)
End If
End If
Next
End With
Set objPic = Nothing
End Sub

2
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Bilder einfügen
30.11.2017 09:07:57
Nepumuk
Hallo Tippi,
teste mal:
Sub insertPicturesTest()
Dim objPic As Shape
Dim lngRow As Long, lngLast As Long
Dim strFile As String
Dim S
For Each objPic In ActiveSheet.Shapes
If Not Intersect(objPic.TopLeftCell, Range("F:F")) _
Is Nothing Then objPic.Delete
Next objPic
Const cstrPath As String = "R:\Logistik\"  'Pfad
Const cstrExtention As String = ".jpg"
Const dblOHeight As Double = 10
Const dblOWidth As Double = 10
With Sheets("Tabelle1") 'Tabellenname anpassen!
lngLast = Application.Max(1, .Cells(.Rows.Count, 2).End(xlUp).Row)
For lngRow = 11 To lngLast
If Not IsEmpty(.Cells(lngRow, 2).Value) Then
strFile = Dir(cstrPath & .Cells(lngRow, 2).Value & cstrExtention, vbNormal)
If strFile  "" Then
Set objPic = .Shapes.AddPicture(Filename:=cstrPath & strFile, _
LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, _
Left:=.Cells(lngRow, 6).Left, Top:=.Cells(lngRow, 1).Top, _
Width:=-1, Height:=-1)
objPic.LockAspectRatio = False
objPic.Height = .Cells(lngRow, 2).Height
objPic.Width = dblOWidth * (objPic.Height / dblOHeight)
End If
End If
Next
End With
Set objPic = Nothing
End Sub

Gruß
Nepumuk
Anzeige
AW: Bilder einfügen
30.11.2017 09:26:29
Tippi
Läuft Supi danke Nepumuk
Ihr seid die besten :)

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige