title: VBA - Identifying whether a string is a file, a folder or a web url
body: <p>I need to perform a number of actions, initiated by the passing of a string, with the course of actions depending on whether the string is a file, a folder or a web url.</p>
  
  <p>FYI - for a file I copy the file to a repository, for a folder I am making a shortcut .lnk and copy that to a repository, and for a web url I am making a shortcut .url and copy that to a repository.</p>
  
  <p>I developed a solution, but it isn't robust enough; I get the occasional error from misidentifying the string. The method I used was to count the dots in the string, and apply the rule:</p>
  
  <pre><code>If Dots = 1 Then... it's a file.
  
  If Dots &lt; 1 Then... it's a folder.
  
  If Dots &gt; 1 Then... it's a website.
  </code></pre>
  
  <p>I then improved this using a couple of functions I found on the web:</p>
  
  <pre><code>Dots = Len(TargetPath) - Len(Replace(TargetPath, ".", ""))      ' Crude check for IsURL (by counting Dots)
  
  If CheckFileExists(TargetPath) = True Then Dots = 1             ' Better check for IsFile
  
  If CheckFolderExists(TargetPath) = True Then Dots = 0           ' Better check for IsFolder
  </code></pre>
  
  <p>Trouble is, I am still having problems with 2 circumstances:</p>
  
  <ol>
  <li><p>When filenames contain additional dots, e.g. <code>\Report.01.doc</code></p></li>
  <li><p>When the string is a file or folder on a remote intranet location (I think this could be misidentifying as a web url).</p></li>
  </ol>
  
  <p>Any pointers in the right direction would be much appreciated.</p>
  
  <p>Tom H</p>