AW: PDF in verzeichnis suchen und öffnen
19.10.2019 20:11:14
Nepumuk
Hallo Manuel,
Aufrufen musst du das so:
Call Suchen(ListBox.Text)
Option Explicit
Private Declare Function SearchTreeForFile Lib "imagehlp.dll" ( _
ByVal RootPath As String, ByVal InputPathName As String, _
ByVal OutputPathBuffer As String) As Long
Private Declare Function ShellExecuteA Lib "shell32.dll" ( _
ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Private Const MAX_PATH As Long = 260
Private Const SW_MAXIMIZE As Long = 3
Private Const FOLDER_PATH As String = "T:\A\B\"
Public Sub Suchen(ByVal pvstrFilename As String)
Dim strPath As String * MAX_PATH
Dim lngReturn As Long
lngReturn = SearchTreeForFile(FOLDER_PATH, pvstrFilename & ".pdf", strPath)
If lngReturn = 0 Then
Call MsgBox("Datei nicht gefunden.", vbExclamation, "Hinweis")
Else
strPath = Left$(strPath, InStr(strPath, vbNullChar) - 1)
Call ShellExecuteA(Application.hwnd, "OPEN", strPath, vbNullString, vbNullString, SW_MAXIMIZE)
End If
End Sub
Gruß
Nepumuk