Hello everyone. I having been updating some VBA code and now get a compile error 13 Type mismatch. This following code worked until I recompiled the module in Access 2016.
It appears that the Declared Function is not being seen by the calling Function( lenret =WinGetTempDir(BufferLen, wrkPath)). I hope this is clear. Please help. Thanks in advance.
It appears that the Declared Function is not being seen by the calling Function( lenret =WinGetTempDir(BufferLen, wrkPath)). I hope this is clear. Please help. Thanks in advance.
Code:
Option Compare Database
'
' Get path of local Windows temporary folder - declaration part
'
#If Win64 Then
Public Declare PtrSafe Function WinGetTempDir Lib "kernel32" Alias "GetTempPathA" (ByVal Buflen As LongPtr, ByVal TempPath As String) As LongLong
#Else
Private Declare Function WinGetTempDir Lib "kernel32" Alias "GetTempPathA" (ByVal BufLen As Long, ByVal TempPath As String) As Long
#End If
---------------------------------
Public Function GetWinTempDir() As String
'
' Get path of local Windows temporary folder - return path as a string
'
Dim wrkPath As String
Dim lenret As Long
Dim BufferLen As Long
wrkPath = String$(255, 0) ' Fill with nulls
BufferLen = 255
lenret = [COLOR="Red"]WinGetTempDir(BufferLen, wrkPath)[/COLOR]
If lenret = 0 Then
GetWinTempDir = ""
Else
GetWinTempDir = Left$(wrkPath, lenret)
End If
End Function