Bildgröße in Pixeln auslesen, Excel 2000
24.02.2007 22:04:05
Kasimir
Ich habe da mal eine Frage, zu einem Makro, dass ich zum Teil in der Recherche gefunden habe. Mit nachfolgendem Makro kann ich aus einem Bild, die Eigenschaften und hier speziell die Breite und Höhe in Pixelangaben, auslesen. Nun ist mir aber aufgefallen, dass dieser Code in Excel 2000 so nicht funktioniert.
Option Explicit
Sub Bildeigenschaften()
Dim Drive As String, Pfad As String
Dim objShell As Object, objFolder As Object
Dim varName As Object, Breite As Variant, Höhe As Variant
Dim sPath As Variant, sFile As String
Dim Bild As Variant
Drive = Left(ThisWorkbook.Path, 2)
Pfad = "C:\"
ChDrive (Drive)
ChDir (Pfad)
Bild = Application.GetOpenFilename( _
"Bilddateien (*.JPG), *.xls, Alle Dateien (*.*), *.*", 1, _
"Bild auswählen...", MultiSelect:=False)
If Bild = "" Or Bild = False Then Exit Sub
If Right(Bild, 3) <> "jpg" Then Exit Sub
If Bild = False Then Exit Sub
sFile = Dir(Bild)
sPath = Replace(Bild, sFile, "")
sPath = Left(sPath, Len(sPath) - 1)
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(sPath)
For Each varName In objFolder.Items
If varName = sFile Then
Breite = objFolder.GetDetailsOf(varName, 27)
Höhe = objFolder.GetDetailsOf(varName, 28)
Exit For
End If
Next
Breite = CInt(Mid(Breite, 1, InStr(1, Breite, " ") - 1))
Höhe = CInt(Mid(Höhe, 1, InStr(1, Höhe, " ") - 1))
MsgBox Breite & " , " & Höhe
Das Problem ist, dass mir der Code in Excel 2003 die Breite und Höhe ausgibt. In Excel 2000 leider nicht. Es kommt zu einem Laufzeitfehler 91 und die Zeile
For Each varName In objFolder.Items
wird gelb markiert. Weiß jemand, warum das so ist?
Danke Euch,
Kasimir