gallen
Well-known Member
- Joined
- Jun 27, 2011
- Messages
- 2,016
I've got this working on a couple of other similar sheets but I must be missing something here.
In short I'm opening a workbook, copying a range, pasting the range in to another Workbook.
However, now when I paste it is pasting an image file not the actual cells.
My code is here:
What am I missing?
In short I'm opening a workbook, copying a range, pasting the range in to another Workbook.
However, now when I paste it is pasting an image file not the actual cells.

My code is here:
Code:
Private Sub ImportPlans()
'****************************************************************************************************************
'Sub to open all plans with same Week Commencing date as the one on the sheet and import them into this workbook*
'****************************************************************************************************************
On Error GoTo errHandle
Dim Summary As Worksheet
Dim ImportFrom As Workbook 'Runplan to import
Dim sFileLoc As String 'location of File to open
Dim sUnit As String
Dim sYear As String
Dim sFileName As String
Dim ExL As New Excel.Application
Enable False
sUnit = "5" ' for TEST PURPOSES ONLY!. Ultimately, the unit will be passed as a string variable from the values on the "Data" sheet
sYear = GetYear
sFileName = GetFileName(sUnit)
sFileLoc = Sheet3.Range("_Plans_5").Value & sYear & sFileName
If CheckFileExists(sFileLoc) = False Then
MsgBox "Error finding Unit: " & sUnit & "'s plan. Please check file exists and is in correct location.", vbCritical, "Can't find file for this week"
Enable True
Exit Sub
End If
'open the workbook with plan to import
Set ImportFrom = ExL.Workbooks.Open(sFileLoc, True, True)
ImportFrom.Sheets(1).Range("Print_Area").Copy
Sheet2.Range("_Plan1").PasteSpecial xlPasteAll
ExL.Application.DisplayAlerts = False
ImportFrom.Saved = True
ExL.Application.DisplayAlerts = False
ExL.Workbooks.Close
Enable True
Exit Sub
errHandle:
MsgBox Err.Description
Enable True
End Sub
What am I missing?
Last edited: