+ Reply to Thread
Results 1 to 2 of 2

Macro to paste between workbooks only works in single instance of Excel

  1. #1
    Registered User
    Join Date
    03-24-2016
    Location
    Washington, DC
    MS-Off Ver
    2010
    Posts
    41

    Macro to paste between workbooks only works in single instance of Excel

    Hi again! I have a macro to paste whatever's in a user's clipboard into a specific sheet in a workbook when the user clicks a button (it also does a few other steps). It works fine when both the data workbook (where the user is copying from) and the report workbook (containing the macro, where the user is pasting to) are open in the same instance of Excel.

    However, I get an error message "Run-time error '1004': PasteSpecial method of Range class failed" when the data workbook and the report workbook are opened in separate instances of Excel. The Debug brings me to the "Selection.PasteSpecial" row of code.

    Here's the code:
    Please Login or Register  to view this content.
    I was getting a different error at one point, hence the "On Error" code - which was fine to ignore - everything still worked perfectly. However, when I try to ignore this error with similar code, no content gets pasted.

    Thoughts? Thanks in advance!

  2. #2
    Forum Contributor
    Join Date
    10-19-2012
    Location
    Omaha, Nebraska USA
    MS-Off Ver
    Excel 2010
    Posts
    249

    Re: Macro to paste between workbooks only works in single instance of Excel

    Hi xdrenched,

    I believe you need to be in the same session for the more advanced options of "PasteSpecial" to be available. If you are pasting from the clipboard, then I think it can only be pasted as Unicode or Text.

    I would suggest if you know the range you are copying, open the reference workbook read-only within your code and copy the pertinent data and then it should paste per your code above and then close the reference workbook once the paste is complete.

    Here is some example code of what I'm describing:

    Please Login or Register  to view this content.
    Hope that helps,

    Dan

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Macro works on single cell paste but not on multiple cell paste
    By jonyorker in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-21-2016, 10:02 AM
  2. Replies: 0
    Last Post: 06-08-2015, 03:56 AM
  3. [SOLVED] Force all workbooks into a single instance of Excel always?
    By ks100 in forum Excel General
    Replies: 3
    Last Post: 01-08-2014, 03:30 PM
  4. How to open workbooks in same instance of Excel 2007
    By sumdumgai in forum Excel General
    Replies: 5
    Last Post: 11-13-2013, 04:22 PM
  5. Macro works well on single file but not on all files in a single directory
    By dnganatra in forum Word Programming / VBA / Macros
    Replies: 6
    Last Post: 08-19-2013, 02:15 AM
  6. Macro To Extract Data From Multiple Workbooks To A Single Sheet - Excel
    By Joshdm0716 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-15-2013, 12:12 PM
  7. To copy data from two different excel workbooks in a single workbook using macro
    By neha_gunaji in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-11-2012, 03:28 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1