Compile error bei GetDirectory.... (Add-In)
kk3003
ich habe seit Kurzem einen Kompilierungsfehler bei der Methode GetDirectory(), die auf die shell32.dll zugreift. Die Exception wird hier anscheinend bei "Space$(512)" erzeugt.
Das ganze passiert erst seit kurzer Zeit. Habe ich vll etwas erforderlich deinstalliert oder ist das eine Standard-DLL.
Nach dem erfolglosen Öffnen des Add-Ins kommt es auch vor, dass Excel meint, das sei kein gültiges Add-In mehr. :/
Bitte um Hilfe.... Danke!
Hier der Code:
Option Explicit
Public Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
Declare
Function SHGetPathFromIDList Lib "shell32.dll" _
Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Declare
Function SHBrowseForFolder Lib "shell32.dll" _
Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Function GetDirectory(Optional Msg As String) As String
Dim bInfo As BROWSEINFO
Dim Path As String
Dim r As Long, X As Long, pos As Integer
bInfo.pidlRoot = 0&
If IsMissing(Msg) Then
bInfo.lpszTitle = "Wählen Sie bitte einen Ordner aus."
Else
bInfo.lpszTitle = Msg
End If
bInfo.ulFlags = &H1
X = SHBrowseForFolder(bInfo)
Path = Space$(512)
r = SHGetPathFromIDList(ByVal X, ByVal Path)
If r Then
pos = InStr(Path, Chr$(0))
GetDirectory = Left(Path, pos - 1)
Else
GetDirectory = ""
End If
End Function