Log in

View Full Version : 64-bit support



lesaussice
10-08-2012, 12:57 AM
The time has come (without going into specifics) where I need to be supporting 64-bit Office, but also need to maintain compatibility back to Office 2003.

Changing API declarations for Win32 libraries is straightforward, as is regular variable declaration within a procedure by using conditional compilation.. But what about declaring variables in the parameters of a function?

ie

Public Function MyFunction (lngLong1 as LongPtr, lngLong2 as LongPt)
<some code>
some.thing=lngLong1
something.else=lngLong2
<some code>
End Function

That will work fine on Office '10, but I have no option but to support Office 2003 (clients). How do I convert that to conditionally compile?

macropod
10-08-2012, 04:17 AM
Do be aware that 32-bit Addins will not work with 64-bit Office. For that reason, MS recommends only installing Office in 64-bit mode where really necessary (mostly to do with humungous Excel workbooks).

lesaussice
10-08-2012, 04:21 AM
Yes I agree, there aren't many situations where you'd install it - but as you've noted, the big Excel workbooks (and the extra capability that gives in terms of Powerpivot etc) are a big draw for some industry sectors. If a client deploys it, I have to support it.

Aflatoon
10-08-2012, 05:57 AM
You have to create two versions of the function and put both inside conditional compilation directives.

lesaussice
10-08-2012, 05:58 AM
Ah okay, that's what I was afraid of! Not ideal, but no choice in this instance I think.

Thanks!

Aflatoon
10-08-2012, 06:29 AM
Actually I just did a quick test and it seems you can simply make the declaration line conditional, though I think it may end up less confusing to create separate routines in most cases.

lesaussice
10-08-2012, 08:44 AM
Actually I just did a quick test and it seems you can simply make the declaration line conditional, though I think it may end up less confusing to create separate routines in most cases.
How did you structure that line? I tried something along those lines but couldn't get it to work... I suspect it was finger trouble, though :blush

Aflatoon
10-08-2012, 08:50 AM
basically
#If VBA7 Then
Public Function Blah(args as LongPtr)
#Else
Public Function Blah(args as Long)
#End If

lesaussice
10-08-2012, 08:55 AM
Ah yeah that works a treat, thanks!