title: VBA Open any workbook
body: <p>I have a macro that opens a spreadsheet from a specific folder and saves the output to a worksheet called Sheet1 in another workbook. The macro works if the file name is called "MyFile.xls" but i would like it to be able to run on any file name but it must have a "Book2" worksheet.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>Dim source As Workbook
  Dim output As Workbook
  Dim sourceSheet as WorkSheet
  Dim outputSheet as WorkSheet
  Dim file As String
  file = "C:\Spreadsheets\MyFile.xls"  'I would like it to handle any files from any location'
  
  Set output = ThisWorkBook
  output.Activate
  
  If Len(Dir$(file)) &gt; 0 Then
      Set source = workbooks.Open(file)
  
  Set sourceSheet = source.Worksheets("Book2") 'Must only run if the sheet is called Book2'
  Set outputSheet = output.Worksheets("Sheet1") 'Saves sheets into a new sheet called Sheet1'
  
  End Sub
  </code></pre>