Copy Data From External Workbook Without Opening

vthokienj

Board Regular
Joined
Aug 1, 2011
Messages
97
I would like to copy data from an external workbook and save it into my current workbook. There is plenty of code for this. What I have not found is how to do this without the external workbook ever opening. Is this possible and how would you do this?

All I can see related to this is using the ActiveWindow.Visible = false statement below, but the external workbook still opens first prior to this statement executing. I just want to get data from that workbook without either the time involved in loading/displaying the workbook or having macros like the workbook_open() executing.

Thanks


Code:
    Dim wbExternal As Workbook, wbInternal As Workbook
    Dim wsExternal As Worksheet, wsInternal As Worksheet
    Dim filePath As String: filePath = "C:\a\readfrom.xlsm"
    Dim wkbSource As Workbook
    Dim wkbDest As Workbook
    Dim sheetToCopy1 As Worksheet
    
    Set wkbDest = thisWorkbook
    Set wkbSource = Application.Workbooks.Open(filePath)
    ActiveWindow.Visible = False
    Set sheetToCopy1 = wkbSource.Sheets(sheetnameObjectives)
    sheetToCopy1.Copy after:=wkbDest.Sheets(1)
 

Some videos you may like

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Watch MrExcel Video

Forum statistics

Threads
1,099,124
Messages
5,466,828
Members
406,501
Latest member
TheoDoc

This Week's Hot Topics

Top