Compile Error after migration to Office 365

bfreescott

Board Regular
Joined
Aug 6, 2015
Messages
115
A client of mine is getting a compile error in hidden module after being migrated from Office 2016 to Office 365. There were no changes to the code. Other clients still on the 2016 platform are reporting no issues with the same code. I've checked for missing libraries in the References, but there were none. In the offending module, all procedures have error handling, none are which are triggered. I'm guessing the compile issue precedes any attempt for run-time. Only one reference to a library is made where I build a connection string using Microsoft.ACE.OLEDB.12.0. I don't think the reference is the issue, as that works fine for all other Excel 2016 clients, but I'm wondering about the version of the engine. Do I need to use version 16.0? I'm also wondering if the issue is 32-bit versus 64-bit. Could there be a conflict there?
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
There is no way to answer this question without seeing the code. Please show the code, give the compile error message, and indicate which line of code causes the error.

Normally there is not an issue in upgrading versions of Excel; it's more common to have backwards compatibility problems. It's possible that 32 vs 64 is an issue but this generally occurs if you are using low-level DLL calls. Hence the request to see your code.
 
Upvote 0
Just wanted to follow up on this issue in case anyone else has this problem and also to thank 6StringJazzer for replying.

The issue was indeed a 32-bit vs 64-bit problem.

Despite backwards compatibility, if you use ADO, 64-bit Excel will throw a compile error on Long variables.
With ADO on a 64-bit Excel platform, you cannot use Long or even LongLong. You must switch to Variant and allow Excel to allocate the memory space at runtime.

This is true for both 32 and 64 bit Windows.

HTH
 
Upvote 0
This depends on what the variable is. Pointers must be declared as LongPtr. I would steer you away from Variant to solve a problem like this. Normally if code has to be compatible with both, compiler directives are used to select which code to include.

I have used ADO without regard to whether the environment is 32 or 64. I would be very curious to see what code you are using that would give you a compile error on Long variables.
 
Upvote 0
LongPtr only resolves to either Long or LongLong. I tried all three with no luck. It wasn't until I found an obscure reference to ADO by a developer on S.O. who recommended Variant that the compile error went away.
 
Upvote 0
Well, if it works great. If you don't want to show your code, OK. But it might be helpful to others (like me) who would like to see your solution.
 
Upvote 0
Well, if it works great. If you don't want to show your code, OK. But it might be helpful to others (like me) who would like to see your solution.
Sorry, I left out one piece of critical info. It's the RecordCount property of the RecordSet object in ADO that dictates that Variant type in 64-bit Excel. I don't know why this is the case; I only know that it was the solution.
 
Upvote 0

Forum statistics

Threads
1,214,951
Messages
6,122,446
Members
449,083
Latest member
Ava19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top