title: VBA Check if file (from website) exists
body: <p>Please bear with me as I am a beginner at VBA.</p>
  
  <p>I am trying to open an excel file through a website using VBA. The address (path) of the file changes from month to month. For example:</p>
  
  <ul>
  <li><p>In July, the file name is: <a href="http://www.clevelandfed.org/research/data/inflation_expectations/2014/July/excel1.xls" rel="nofollow noreferrer">http://www.clevelandfed.org/research/data/inflation_expectations/2014/July/excel1.xls</a></p></li>
  <li><p>In August, the file name is: <a href="http://www.clevelandfed.org/research/data/inflation_expectations/2014/August/excel1.xls" rel="nofollow noreferrer">http://www.clevelandfed.org/research/data/inflation_expectations/2014/August/excel1.xls</a></p></li>
  </ul>
  
  <p>The problem is that I never know in advance when the new file for the month is going to be published. Therefore, I need to check in the VBA code if the current month file exist, if not, I would just open the previous month file.</p>
  
  <p>This is what I have tried:</p>
  
  <pre><code>Dim DirFile As String
  Dim wbA As Workbook
  
  DirFile = "http://www.clevelandfed.org/research/data/inflation_expectations/" &amp; Format(Now, "YYYY") &amp; "/" &amp; Format(Now, "MMMM") &amp; "/excel1.xls"
  
  ' Check if the file for current month does not exist, open previous month's file
  If Len(Dir(DirFile)) = 0 Then
      Set wbA = Workbooks.Open("http://www.clevelandfed.org/research/data/inflation_expectations/" &amp; Format(Now, "YYYY") &amp; "/" &amp; Format(DateAdd("m", -1, Date), "MMMM") &amp; "/excel1.xls", IgnoreReadOnlyRecommended:=True)
  
  'If the current month file exists, open it
  Else
      Set wbA = Workbooks.Open(DirFile, IgnoreReadOnlyRecommended:=True)
  End If
  </code></pre>
  
  <p>However, this results in an error:</p>
  
  <p><img src="https://i.stack.imgur.com/OldAP.jpg" alt="enter image description here"></p>
  
  <p>I am assuming this is due to the fact that this is a file that resides on a website. Could anyone please help resolve this issue?</p>
  
  <p>Thank you!</p>