1 1 1 1 1 1 1 1 1 1 Rating 0.00 (0 Votes)

Für 32Bit und 64Bit Office Versionen

Problemstellung:

Wie kann ich das aktuelle temporäre Verzeichnis meines Systems ermitteln?

Folgenden Code in öffentliches Modul kopieren:

#If VBA7 Then
    'Code für 32 bit und 64 bit Office VBA 7
     #If Win64 Then
        'Code für 64-bit Office VBA 7
        Declare PtrSafe Function GetTempPath Lib "kernel32" Alias "GetTempPathA" _
            (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
     #Else
        'Code für 32-bit Office VBA 7
        Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" ( _
            ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
     #End If
#Else
    'Code für VBA 6 (32 bit)
    Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" ( _
        ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
#End If

Public Function GetTempFolder() As String
    Dim strTempFolder As String
    Dim lngRet As Long
    strTempFolder = String(255, 0)
    lngRet = GetTempPath(255, strTempFolder)
    If lngRet <> 0 Then
        strTempFolder = Left(strTempFolder, lngRet)
        GetTempFolder = Left(strTempFolder, _
            Len(strTempFolder) - 1)
    End If
End Function

Aufruf:

MsgBox GetTempFolder

Ergebnis:


 

Ähnliche Artikel