Excel macros in 64 bit office

BrianMD

New Member
Joined
Feb 10, 2020
Messages
2
Office Version
  1. 2010
Platform
  1. Windows
I am trying to upgrade my VBA declare statements so they work on 32 and 64 version of office. I'm assuming all the users are on VBA 7 or later. I copied the code below from this forum and it works perfectly but for completeness, should I change the other 'Long' to LongPtr throughout as in the second example?

Private Declare PtrSafe Function MsgBoxTimeOut Lib "user32" Alias "MessageBoxTimeoutA" ( _
ByVal hwnd As LongPtr, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As VbMsgBoxStyle, _
ByVal wlange As Long, ByVal dwTimeout As Long) As Long

Private Declare PtrSafe Function MsgBoxTimeOut Lib "user32" Alias "MessageBoxTimeoutA" ( _
ByVal hwnd As LongPtr, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As VbMsgBoxStyle, _
ByVal wlange As LongPtr, ByVal dwTimeout As LongPtr) As LongPtr

It's an excellent way to pop up a time expiring message and doesn't upset the virus checker.

Thanks.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Welcome to the forum.

No, only the hWnd needs to be a LongPtr.
 
Upvote 0

Forum statistics

Threads
1,215,135
Messages
6,123,239
Members
449,093
Latest member
Vincent Khandagale

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