title: With VBA, how to import a xlsx file into a xlsm without opening the xlsx file?
body: <p>This is part of my current code:</p>
  
  <p>Option Explicit</p>
  
  <pre><code>Sub ImportData()
  
      Dim wkbCrntWorkBook As Workbook
      Dim wkbSourceBook   As Workbook
      Dim fNameAndPath As Variant
  
      Set wkbCrntWorkBook = ActiveWorkbook
      fNameAndPath = Application.GetOpenFilename(FileFilter:="Excel 2007, *.xlsx; *.xlsm; *.xlsa", Title:="Select File To Import")
      If fNameAndPath = False Then Exit Sub
      Call ReadDataFromCloseFile(fNameAndPath)
  
  
      Set wkbCrntWorkBook = Nothing
      Set wkbSourceBook = Nothing
  
  End Sub
  
  Sub ReadDataFromCloseFile(filePath As Variant)
      On Error GoTo ErrHandler
      Application.ScreenUpdating = False
  
      Dim src As Workbook
  
      Set src = Workbooks.Open(filePath, True, True)
  
  ' COPY DATA FROM SOURCE (CLOSE WORKGROUP) TO THE DESTINATION WORKBOOK.
  ' GET THE TOTAL ROWS FROM THE SOURCE WORKBOOK.
  Dim lastLine As Long   ' last line from source
  lastLine = src.Worksheets(source_sheet_1_name).Range("A" &amp; Rows.count).End(xlUp).Row
  Worksheets("abc").Range("A3:A40")).Value= src.Worksheets("cde").Range("A4:A41").Value
  
  
  ' CLOSE THE SOURCE FILE.
  src.Close False             ' FALSE - DON'T SAVE THE SOURCE FILE.
  Set src = Nothing
  
  ErrHandler:
      Application.EnableEvents = True
      Application.ScreenUpdating = True
  End Sub
  </code></pre>
  
  <p>According to <a href="http://www.encodedna.com/excel/copy-data-from-closed-excel-workbook-without-opening.htm" rel="nofollow noreferrer">this</a>, the source workbook of the data will not be opened. However, as soon as I clicked the file name in the file browser to select the file to be imported, excel opened the file.</p>
  
  <p>Does anyone know how I should achieve the objective (regardless of the link in the last paragraph)?</p>
  
  <p>(My objective is to copy/import certain columns from an xlsx file to xlsm file according to certain criterien automatically after the user indicate the file to be imported (without opening the file to be imported). However, after I select the file to be imported by double click, the file to be imported is merely opened. The program does not carry forward to import the corresponding columns after the file to be imported is open.)</p>