title: Compiling error VBA macro taken from internet
body: <p>I took this code from the internet to find an exe file on the harddrive, namely, Word, since I cannot find it.  </p>
  
  <pre><code>Sub FindExcelExe()
      MsgBox LocateExecutable("C:\WorkbookTest\Boktest2.xlsx")
  End Sub
  ' **** Source - http://www.utteraccess.com/forum/Excel-File-Foreground-t1982963.html
  </code></pre>
  
  <p>It complains on this code --></p>
  
  <pre><code>Private Declare Function FindExecutable Lib "shell32" Alias "FindExecutableA" ( _
    ByVal lpFile As String, _
    ByVal lpDirectory As String, _
    ByVal sResult As String _
  ) As Long
  </code></pre>
  
  <p>&lt;-- Error: May only exist comments after End Sub, End function....</p>
  
  <pre><code>Private Const MAX_PATH As Long = 260
  
  Function LocateExecutable(PathToFile) As String
  
  Dim lngPosition As Long
  Dim lngResult As Long
  Dim strFile As String
  Dim strPath As String
  Dim strPathToExecutable As String
  
    strFile = Dir(PathToFile)
    If Len(strFile) &gt; 0 Then
      strPath = Left$(PathToFile, Len(PathToFile) - Len(strFile))
      strPathToExecutable = Space$(MAX_PATH)
  
      lngResult = FindExecutable(strFile, strPath, strPathToExecutable)
  
      If lngResult &gt;= 32 Then
        lngPosition = InStr(strPathToExecutable, Chr$(0))
        If lngPosition &gt; 0 Then
          LocateExecutable = Left$(strPathToExecutable, lngPosition - 1)
        End If
      End If
    End If
  
  End Function 
  </code></pre>
  
  <p>Thanks a bunch!</p>