so funtzt es
27.02.2008 00:31:00
holger
Hallo
Private Sub CommandButton1_Click()
On Error Resume Next
Dim name As String
Dim vname As String
Dim bewbildpfad As String
name = WUND.TextBox11.Value
vname = WUND.TextBox12.Value
bewbildpfad = ThisWorkbook.Sheets("Daten").Range("J4")
cntBild = cntBild + 1
With Application.FileSearch
.LookIn = bewbildpfad
.filename = name & ", " & vname & "*.jpg"
.Execute SortBy:=msoSortByLastModified
strFile = (.FoundFiles(cntBild))
strname = Trim$(Left(strFile, InStr(1, strFile, ",") - 1))
strFile = Trim$(Mid(strFile, InStr(1, strFile, ",") + 1))
strFile = Left(strFile, InStrRev(strFile, ".") - 1)
strVName = Trim$(Left(strFile, Len(strFile) - 10))
datDatum = CDate(Right(strFile, 10))
If .FoundFiles.Count >= cntBild Then
Me.Image1.Picture = LoadPicture(.FoundFiles(cntBild))
Me.Label1 = datDatum
Else
If MsgBox("Letztes Bild wurde angezeigt!" & vbLf & vbLf & _
"Soll das erste Bild angezeigt werden?", vbQuestion + vbYesNo, "Frage") = vbYes _
Then
cntBild = 1
strFile = (.FoundFiles(cntBild))
strname = Trim$(Left(strFile, InStr(1, strFile, ",") - 1))
strFile = Trim$(Mid(strFile, InStr(1, strFile, ",") + 1))
strFile = Left(strFile, InStrRev(strFile, ".") - 1)
'strVName = Trim$(Left(strFile, Len(strFile) - 10))
datDatum = CDate(Right(strFile, 10))
Me.Image1.Picture = LoadPicture(.FoundFiles(cntBild))
Me.Label1 = datDatum
Else
cntBild = 0
End If
End If
End With
End Sub
habe denn fett markierten teil nochmals einfügen müssen um nach der abfrage durch die msgbox auch beim ersten bild das richtige datum wieder zuhaben. geht bestimmt auch einfacher (-:
danke und gruß
holger