Hi,
On our company we are switching from 32 to 64-bit Office. I invoke API code and get compile error after installing 64-bit office. I've read online it's possible to get API to work on both 32 and 64-bit by applying code:
#If VBA7 Then
Declare PtrSafe Sub...
#Else
Declare Sub...
#EndIf
I've adapted my code to above but still I get syntax error below on 64-bit installed Office.
#If VBA7 Then
'Add PtrSafe to be able to run on 64-bit
'THIS CODE IS OK ON 64-bit OFFICE
Declare PtrSafe Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
(ByVal lpbuffer As String, nSize As Long) As Long
#Else
'Remove PtrSafe to be able to run on 32-bit
'THIS CODE RETURNS SYNTAX ERROR ON 64-bit OFFICE
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
(ByVal lpbuffer As String, nSize As Long) As Long
#End If
Any ideas what I'm doing wrong?
Bookmarks