Results 1 to 15 of 15

Thread: Copy and Paste Error between Application instances

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Administrator
    2nd VP-Knowledge Base
    VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location

    Copy and Paste Error between Application instances

    Hey everyone,

    I can't figure this one out. I'm getting "Copy method of Range class failed":

    Public Sub ImportDataNow(ByVal xlWB As Excel.Workbook, _
    ByVal xlSh As Excel.Worksheet, ByVal xlDataRange As Excel.Range)
    ' This will perform the actual importing process to a new workbook.
    Dim wbData As Excel.Workbook
    Dim shData As Excel.Worksheet
    ' Create new workbook to import data
    Application.Workbooks.Add
    Set wbData = ActiveWorkbook
    Set shData = wbData.Sheets("Sheet1")
    shData.Name = "Scheduling Import - " & MonthName(Month(Now()), False)
    ' Import
    xlWB.Worksheets(xlSh.Name).Range(xlDataRange.Address(0, 0)).Copy shData.Range("A1")
    End Sub

    If need be I'll post the whole code.

    If it helps the range address that's copied is: "A1:AG2,A3329:AG3575"
    And the workbook I'm copying from is opened Read-Only, but not sheet/workbook protected.

    I don't know what else to say...
    Last edited by Aussiebear; 04-16-2023 at 03:15 PM. Reason: Adjusted the code tags




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •