title: How to test if an application and workbook are opened
body: <p>I am looking for help on trying to figure out how to check if a particular workbook is opened. I have a button on my Windows form that when pressed, it will open Excel and go to a particular worksheet. However, I just ran into the problem that the user may already have that particular workbook open, so instead of creating a new instance of Excel and opening the workbook again, I want to check if that workbook is opened, if it is, then go to the selected worksheet.</p>
  
  <p>Here is the code I have so far:</p>
  
  <pre><code>Private Sub btnMinSummaryWorksheet_Click(sender As Object, e As EventArgs) Handles btnMinSummaryWorksheet.Click
      'This procedure runs when the btnOpenSummaryWorksheet button is clicked. Calls the
      'Sub procedure opens the Summary Worksheet Dashboard
  
      Dim xlApp As New Excel.Application
      xlApp.Visible = True
  
      Dim xlBook As Excel.Workbook
      xlBook = xlApp.Workbooks.Open("F:\Test Environment\Compensation Workbook\Compensation Workbook\bin\Debug\2011.1004.Compensation Template.xlsx")
  
      Dim xlSheet As Excel.Worksheet
      xlSheet = CType(xlBook.Sheets("SummaryWorksheet"), Worksheet)
      xlSheet.Activate()
  
      Me.Close()
  End Sub
  </code></pre>