We help IT Professionals succeed at work.
Troubleshooting Question

VBA-Can my code be modified to work on both Office 2016 and Office 365?

Last Modified: 2020-10-23
Only uses that are using Office 365 get an error for the below code when the file is opened.  Can it be modified to work on both Office 2016 and Office 365?

Option Explicit
Private Declare Function ShellExecute _
  Lib "shell32.dll" Alias "ShellExecuteA" ( _
  ByVal hwnd As Long, _
  ByVal Operation As String, _
  ByVal Filename As String, _
  Optional ByVal Parameters As String, _
  Optional ByVal Directory As String, _
  Optional ByVal WindowStyle As Long = vbMinimizedFocus _
  ) As Long
Watch Question


most probably that could be relating to 32 bit or 64 bit issue.

try read below on how we could handle that.

Compatibility between the 32-bit and 64-bit versions of Office

Group Finance Manager
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)

What are you using shellexecute for? maybe you can use some function or workaround that doesnt need any change in both 64 and 32 versions.
Roy CoxGroup Finance Manager

Pleased to help. When 365 was installed the IT Department must have used 64 bit, using PtrSafe in the example allows the code to run in both versions.

The code that is not relevant to the version in use will show in red, but ignore that.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions