title: Visual Studio 2015 - Manipulating Excel?
body: <p>I have 750 Excel files that I want to </p>
  
  <ol>
  <li>clean by deleting columns of data that have a heading with an asterisk, </li>
  <li>then take some of that data and put it in a new workbook worksheet, and other data into the same workbook worksheet, and some other data into a second new workbook.</li>
  </ol>
  
  <p>I created a WPF project in Visual Studio 2015 with a little dialog box with 2 radio buttons for </p>
  
  <ol>
  <li>clean data, </li>
  <li>produce new files.  </li>
  </ol>
  
  <p>This is my VB code:</p>
  
  <pre><code>    Class MainWindow
      Dim wb As Microsoft.Office.Interop.Excel._Workbook
      Dim ws As Microsoft.Office.Interop.Excel._Worksheet
      Dim iCol As Integer
      Dim strName As String
      Dim iIndex As Integer
      Dim strPath As String
      Dim strFile As String
  
      Private Sub button_Click(sender As Object, e As RoutedEventArgs) Handles button.Click
          If cleanRadioButton.IsChecked = True Then
              strPath = "c:\test\old\"
              strFile = Dir(strPath &amp; "*.csv")
              Do While strFile &lt;&gt; ""
  
                  wb = wb.Open(Filename:=strPath &amp; strFile)
  
                  'Loop through the sheets.
                  For iIndex = 1 To Application.Worksheets.Count
                      ws = Application.Worksheets(iIndex)
  
                      'Loop through the columns.
                      For iCol = 1 To ws.UsedRange.Columns.Count
                          'Check row 1 of this column for the char of *
                          If InStr(ws.Cells(10, iCol).Value, "*") &gt; 0 Then
                              'We have found a column with the char of *
                              ws.Columns(iCol).EntireColumn.Delete
                              ws.Columns(iCol + 1).EntireColumn.Delete
                              ws.Columns(iCol + 2).EntireColumn.Delete
                          End If
                      Next iCol
  
                  Next iIndex
                  wb.SaveAs(Filename:="C:\test\new\" &amp; wb.Name, FileFormat:=xlOpenXMLWorkbook)
                  wb.Close(SaveChanges:=False)
                  strFile = Dir()
              Loop
              MessageBox.Show("The csv files have now been cleaned.  Congrats.")
          Else inputRadioButton.IsChecked = True
              MessageBox.Show("The data has now been split into Trajectory and ForcePlate input files.  High 5.")
          End If
      End Sub
  End Class
  </code></pre>
  
  <p><strong>I get 3 errors but can't work out how to solve them</strong>.  </p>
  
  <p>a) Worksheets is not a member of Application [line 19] </p>
  
  <p>b) Worksheets is not a member of Application [line 20] </p>
  
  <p>c)  'xlOpenXMLWorkbook' is not declared.  It may be inaccessible due to its protection level.</p>