title: Find registry key using Excel VBA
body: <p>I want to check if a user has Microsoft SQL Native Client 2008 (sqlncli10) or Native Client 2012 (sqlncli11) installed.</p>
  
  <pre><code>Dim key As String
  Dim myShell As Object
  Set myShell = CreateObject("WScript.Shell")
  
  key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\SQLNCLI11\CurrentVersion\Version"
  'key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentVersion"
  
  Dim strKey As String
  strKey = myShell.RegReadkey(key)
  </code></pre>
  
  <p>When looking for the native client I receive the error:</p>
  
  <blockquote>
    <p>Invalid root in registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft SQL Server\SQLNCLI11\CurrentVersion\Version"</p>
  </blockquote>
  
  <p>but when trying the Windows NT version it works fine.</p>
  
  <p>I replaced HKEY_LOCAL_MACHINE with HKLM: but that doesn't work either.</p>
  
  <p><strong>EDIT</strong> </p>
  
  <p>I just figured it out I think. When I checked in the registry it exists in the 64-bit section. However VBA checks in 32-bit and the root for SOFTWARE becomes Wow6432Node. So it checks in Wow6432Node\Microsoft\Microsoft SQL Server and the key does not exist there. But I have found another path SOFTWARE\Microsoft\Microsoft SQL Server Native Client 10 alternatively 11 which exist in both 32-bit and 64-bit.</p>