Consulting

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. #15
    Administrator
    2nd VP-Knowledge Base
    VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    Awesome! So far, so good. I'll do some testing before I mark this thread solved.

    Here's what I ended up with:
    Public Sub ImportDataNow(ByVal xlApp As Excel.Application, 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
    Set wbData = Application.Workbooks.Add
    Set shData = wbData.Sheets("Sheet1")
    shData.Name = "Scheduling Import - " & MonthName(Month(Now()), False)
    ' Temporarily create new sheet in Production workbook and copy and paste data there
    xlWB.Worksheets(xlSh.Name).Range(xlDataRange.Address).Copy
    With xlWB.Sheets.Add
        .Paste
        .UsedRange.Copy
        ' .PasteSpecial (3) = "Microsoft Excel 8.0 Format"
        wbData.Worksheets(shData.Name).Range("A1").PasteSpecial (3)
        .Delete
    End With
    Call ClearClipBoard
    End Sub
    Now it's time to format and edit my data

    Thanks Tom for the help, much appreciated
    Last edited by Aussiebear; 04-16-2023 at 03:29 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
  •