I have this script that I used for years which stores emails from outlook in a folder on the hard disk for archiving. It always worked great, but no I changed to Office '21 64bit and I get an error message compiling. I have seen similar questions but I'm a total noob, so the question is, can somebody point me to what needs to be changed. The following lines get flagged:
**Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)**
Any input really much appreciated...
To write code that can work in both new and older versions of Office, you can use a combination of the new VBA7 and Win64 conditional Compiler constants. The Vba7 conditional compiler constant is used to determine if code is running in version 7 of the VB editor (the VBA version that ships in Office 2010). The Win64 conditional compiler constant is used to determine which version (32-bit or 64-bit) of Office is running. For example:
#If Win64 Then
Public Declare PtrSafe Function GetTickCount Lib "Kernel32" Alias "GetTickCount64" () As LongPtr
#Else
Public Declare PtrSafe Function GetTickCount Lib "Kernel32" () As LongPtr
#End If
You may find the following articles helpful: