VBA从其他工作簿复制数据而不打开该工作簿

VBA从其他工作簿复制数据而不打开该工作簿,vba,excel,Vba,Excel,我有以下VBA代码: Sub OpenCopyPaste() Dim wb As Workbook Dim Reportwb As Workbook ' set report workbook to workbook object (works only is the file is already open) Set Reportwb = Workbooks("report.xlsx") ' open the source workbook and select the source s

我有以下VBA代码:

Sub OpenCopyPaste()

Dim wb As Workbook
Dim Reportwb As Workbook

' set report workbook to workbook object (works only is the file is already open)
Set Reportwb = Workbooks("report.xlsx")

' open the source workbook and select the source sheet
Set wb = Workbooks.Open(Filename:="C:\Users\Adryan Permana\Downloads\Test\part8.xlsx")

' copy the source range and paste in 1 line , paste at "C3:E9"
wb.Sheets("Sheet1").Range("C3:E9").Copy
Reportwb.Sheets("Sheet1").Range("C3:E9").PasteSpecial xlPasteValues
Reportwb.Save

End Sub
我想复制“part8.xlsx”中的数据而不打开该文件。我该怎么做?非常感谢你的帮助

Sub OpenCopyPaste()
Dim wb As Workbook
Dim Reportwb As Workbook
' set report workbook to workbook object (works only is the file is already 
'open)
Set Reportwb = ThisWorkbook
Application.ScreenUpdating = False
' open the source workbook and select the source sheet
Set wb = Workbooks.Open(Filename:="C:\Users\Adryan Permana\Downloads\Test\part8.xlsx")
' copy the source range and paste in 1 line , paste at "C3:E9"
wb.Sheets("Sheet1").Range("C3:E9").Copy
Reportwb.Sheets("Sheet1").Range("C3:E9").PasteSpecial xlPasteValues
wb.Close False
Reportwb.Save
Application.ScreenUpdating = True
End Sub

试试这个

这里有一些问题:这不符合问题标准:不打开该文件。