+ Reply to Thread
Results 1 to 3 of 3

slow computer (slow clipboard) breaks my macro

  1. #1
    Registered User
    Join Date
    06-03-2013
    Location
    Denver, Colorado, US
    MS-Off Ver
    Mac Office 2011/Windows Office 2013
    Posts
    6

    slow computer (slow clipboard) breaks my macro

    I've got an interesting problem.

    A macro I've made loops over pictures on a worksheet, copies and pastes them (PasteSpecial) to another cell in the sheet. This is working fine with Excel 2011, 2007, and 2013 on a faster computer, but in my testing I've found that the PasteSpecial method fails on a slow computer. This is in Excel 2010, and since this macro's working fine in Excel 2007 and 2013, I assume that the version of Excel isn't the problem (please correct me if that's a bad assumption).

    To clarify, pictures are copied with .Copy, and immediately pasted with .PasteSpecial into another cell, but on the slow computer i get an error 1004, pastespecial failed for range object (since they're being pasted to a particular cell referenced as a range).

    Here's the interesting part: If i put a message box (empty or not) right after the copy command, and sit there clicking ok over and over, then the error is never thrown, and everything works fine (as with the other 3 Excel versions tested).

    I think the msgbox is just giving the slow computers clipboard time to catch up to what's going on, since excel would be waiting for itself if it had stuff to do but might not be smart enough to wait for the slow write speed of the computer itself.

    Is there a way to test if the computers busy so I can make excel wait until the clipboard is caught up? Or maybe test the contents of the clipboard so excel waits until there's actually something to paste?

    Or some other creative solution would be sweet!

    Thanks,

    Tim

  2. #2
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: slow computer (slow clipboard) breaks my macro

    You might add DoEvents between Copy and Paste.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    06-03-2013
    Location
    Denver, Colorado, US
    MS-Off Ver
    Mac Office 2011/Windows Office 2013
    Posts
    6

    Re: slow computer (slow clipboard) breaks my macro

    Bingo!

    Thanks, problem solved. I can imagine the computer responding to the DoEvents like "oh, you wanted me to do that thing you just told me to do. My mistake..."

    Thanks again!

    Tim

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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