I have a VBA application developed in Excel 2007, and it contains the following code to allow access to the ShellExecute
function from Shell32.dll
:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
I originally said:
Apparently the application will not compile on a 64-bit version of Windows (still using 32-bit Office 2007). I assume that this is because the
Declare
declaration needs updated.I've read that Office 2010 introduced a new VBA runtime (VB7), and that this has some new keywords that can be used in the
Declare
statement to allow it to work properly on 64-bit Windows. VB7 also has new predefined compiler constants to support conditional compilation where either the old or new declaration will be used, depending on whether the application is running on 32 or 64-bit Windows.However, since I'm stuck with Office 2007 I need an alternative solution. What are my options? (I'd really prefer not to have to release 2 separate versions of my application if at all possible).
However, per David's answer below, I was mistaken about the circumstances in which my Declare
statement won't work. The only circumstances under which it won't work is Office 2010 64-bit on Windows 64-bit. So, Office 2007 is not an issue.