Compile Error - Versions

Sven62

Active Member
Joined
Feb 21, 2012
Messages
463
Can anyone tell what the prob might be. Getting compile error on start up. Used to work fine. Then they upgraded to Windows 10. I suspect a 32/64 bit confliction. Any suggestions? Thanks

Code:
Option ExplicitPrivate Declare Function ShowWindow _
Lib "user32" _
(ByVal hwnd As Long, _
ByVal nCmdShow As Long) _
As Long
 

Sven62

Active Member
Joined
Feb 21, 2012
Messages
463
I think I found the answer. Need to add "PtrSafe" in between "Declare" and "Function". Also need to change any "Long" or "LongLong" to "LongPtr"
 

theBardd

Rules violation
Joined
Jan 21, 2012
Messages
912
Only the pointers not all longs, and best to cater for 32 and 64-bit with conditional compilation

Code:
#If VBA7 Then
    Private Declare PtrSafe Function ShowWindow Lib "USER32" _
        (ByVal hwnd As LongPtr, ByVal nCmdShow As Long) As Long
[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=Else]#Else[/URL] 
    Private Declare Function ShowWindow Lib "USER32" _
        (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=End]#End[/URL]  If
 

Sven62

Active Member
Joined
Feb 21, 2012
Messages
463
Hey thanks! I got this from Microsoft site

"Writing code that works on both 32-bit and 64-bit Office

To write code that can port between both 32-bit and 64-bit versions of Office, you only need to use the new LongPtr type alias instead of Long or LongLong for all pointers and handle values. The LongPtr type alias will resolve to the correct Long or LongLong data type depending on which version of Office is running."

And that change did not cause any unusual performance on my 64 bit system. I also made the PtrSafe change.
 
Last edited:

Forum statistics

Threads
1,081,983
Messages
5,362,548
Members
400,679
Latest member
alecalec202

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top