title: Check if workbook exists, if yes then check if its open. if open then activate, if closed then open it
body: <p>I am working on a VBA program where I need to do following:</p>
  
  <p>When the button is clicked (the macro is run):</p>
  
  <ol>
  <li><p>Check if the MS EXCEL workbook exists in the folder. If not, then give a message that 'workbook does not exist' and VBA program should end.</p></li>
  <li><p>If workbook exists, then check if workbook closed or open. If its closed, then open the workbook and VBA program should move with fruther steps.</p></li>
  <li><p>If the sheet is open then activate the workbook and VBA program should move with fruther steps.</p></li>
  </ol>
  
  <p>I have written this so far but its not working:</p>
  
  <pre><code>Sub test()
      Dim WbookCheck As Workbook
  
      On Error Resume Next
      Set WbookCheck = Workbooks("Weekly Report.xls")
      On Error GoTo 0
       filepaths = "c:\clients\work\Weekly Report.xls"
      If Dir("filepaths") = False Then
          MsgBox "Please save the latest file under the name 'US Sector Flow Weekly Report' and run the macro again"
          Exit Sub
      ElseIf WbookCheck Is Nothing Then
          Workbooks.Open "c:\clients\work\Weekly Report.xls"
      Else
          WbookCheck.Activate
      End If
  Workbooks("Weekly Report.xls").Activate
  
  Sheets("This week").Select
      Sheets("This week").Copy Before:=Workbooks( _
          "Consolidated.xls").Sheets(1)
  
  End Sub
  </code></pre>