title: "GetCurrentProcessId()" VBA 7 migration
body: <p>I am currently migrating a large Excel tool from VBA 6 and Excel 32bit to VBA 7 with Excel 64bit.</p>
  <p>The kernel32 function &quot;GetCurrentProcessID&quot; is causing excel to crash. I can recreate the error in an empty excel file with the single line of VBA code</p>
  <pre><code>Declare PtrSafe Function GetCurrentProcessId Lib &quot;kernel32&quot; () As Long
  </code></pre>
  <p>If I then call the function within Excel, the number gets populated on the sheet, but Excel crashes after a few seconds. I tried to declare the function with</p>
  <pre><code>Declare PtrSafe Function GetCurrentProcessId Lib &quot;kernel32&quot; () As LongPtr
  </code></pre>
  <p>and other variations, but nothing seems to work. I am running Microsoft Office 365 with 64 bit.</p>
  <p>Did anyone come across this problem before?</p>
  <p>Edit: Sorry, I should have been clearer. The presence of the declaration does not cause Excel to crash. Instead, calling it from the spreadsheet causes the crash. I did notice though that calling it from within VBA does not cause a crash, and a wrapper function can be built such that it can be used again from within the spreadsheet. Very strange, but workable solution.</p>