Long vs Longptr

davidam

Active Member
Joined
May 28, 2010
Messages
497
Office Version
  1. 2021
Platform
  1. Windows
Hello All,
I am just trying to clarify when to use LongPtr as I seem to be getting different input when I search the issue. Can someone please tell me if the following is correct.
VBA Code:
#If VBA7 Then
Declare PtrSafe Function OpenClipboard Lib "User32" _
(ByVal hwnd As LongPtr) As LongPtr
 Declare PtrSafe Function CloseClipboard Lib "User32" () As LongPtr
#Else
Declare  Function OpenClipboard Lib "User32" _
(ByVal hwnd As Long) As Long
 Declare Function CloseClipboard Lib "User32" () As Long
#End If
Many thanks,
David
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Looks ok to me. See if this article helps

As noted therein, you don't have to do this if no one is running 64 bit Office. The bitness of Windows does not matter. You will see code that evaluates whether or not Windows is 64 bit, and AFAIK, that is the wrong approach.
 
Upvote 0
Solution
Great, thank you. The link is the best explanation I have seen.
I guess by now most users, like me, are running 64 bit software. My concern is that a user running 32 bit excel can still use the program.
Thanks again!
David
 
Upvote 0
I installed 32 bit Access as do many others. Most people have no need for what 64 bit offers, and there are compatibility issues between them. IIRC, a db created in 64 bit can't even be opened by 32 bit Access, so why ever go there unless you need the BigInt data type. I believe that is the only difference. At one point the default Access install was 32 (that may have changed). I'd say 99.3214% of users don't need 64, but some IT people seem to have a bigger/faster/newer mindset and go for the latest, but not necessarily the greatest. One has to keep in mind that it has nothing to do with the bitness of Windows, but some make the mistake of thinking if you have 64 bit Windows you must need 64 bit Office.
 
Upvote 0
I am using Excel 2021, 64 bit. It sounds like anyone writing programs for others would be well advised to write them in 32 bit. Even for Excel?
 
Upvote 0
Not sure what you mean. If users could be either Office 32 or 64 and you use API's that need conversion from 32 bit syntax then you have to code for both as per your OP. AFAIK, you need all 3 conditions. Not all API's require conversion.
 
Upvote 0
I read your post: "a db created in 64 bit can't even be opened by 32 bit Access". So, there are no such issues related to Excel, ie anything created with 64 bit Excel can be made compatible with 32 bit as per my OP. But I just wonder why would anyone ever create a 64 bit db in Access?
 
Upvote 0
I prefaced that with IIRC (if I recall correctly) so I may be incorrect. To answer the question regardless, if you're using 64bit Access, you create 64bit versions.
I don't work in 64 bit Office or Access so I must go completely by memory wrt compatibility between bit versions. So
- 64 bit Access creates 64 bit db's and vice-versa for 32 bit
- 32 bit db can be opened by 64 as long as it is not an accde (or I presume, mde)
- 64 bit cannot be opened by 32
HTH
 
Upvote 0

Forum statistics

Threads
1,224,862
Messages
6,181,458
Members
453,042
Latest member
AbdelrahmanExcel

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