VBA pasting is pasting image, not cells

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. :confused:

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:
Yes, it seems that was the issue. Behaves much more normal when I didn't use another instance of Excel. Had to change back to xlPasteAll too.
 
Upvote 0

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Forum statistics

Threads
1,216,069
Messages
6,128,600
Members
449,460
Latest member
jgharbawi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top