+ Reply to Thread
Results 1 to 1 of 1

Copy/Paste command sometimes result in an VBA error

  1. #1
    Registered User
    Join Date
    02-15-2014
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    42

    Copy/Paste command sometimes result in an VBA error

    Hello everyone,

    I'm afraid I'm again in need of your help...

    I have a UserForm with 2 large textbox (because many lines are copied in it). When user enter the text in each textbox, they click on OK button and it will copy/paste each textbox content one after the other from the cell A2.

    Here is the code:

    Please Login or Register  to view this content.

    My problem is, on several PCs the code works just fine. However, on some other PC and sometimes, it doesn't work.
    The line "MyData#.PutInClipboard" OR "Sheet1.Range("A2").PasteSpecial" is highlighted and I get the following error:

    Run-time -2147221040 (800401d0)
    DataObject:PutInClipboard OpenClipboard Failed

    OR

    Run-time error '1001'
    PasteSpecial method of Range class failed

    And once I'm in the debugger, pressing F5 to resume will work just fine and text is copied/pasted properly. So the code works but some PC don't like it...

    I really don't understand because it's really on random PC. But if it happens on a PC, the error will always occur whenever I execute the code.
    I tried adding a delay of 1 second before the paste commands "(Application.Wait (Now + #12:00:01 AM#)". It seemed to work but I'm really not a big fan of adding 2 seconds if there is another way to solve the issue.
    Also, it seems that the same code works fine if there is only 1 textbox.

    May I ask if anyone experienced this or know what could cause this issue?

    Thanks in advance for your help.

    EDIT:
    I tried another document (not from me) using the same copy/paste code and the same issue occurs. Is there a restriction I'm not aware of?
    Last edited by DreamEyes; 05-24-2014 at 09:20 AM.

+ 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. Excel macro (compile error. syntax error.) error
    By salar_younis in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-06-2014, 06:11 AM
  2. Receiving following error “Complie error : syntax error” Help
    By masond3 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-02-2012, 10:19 AM
  3. Error "run-time Error '1004': General Odbc Error
    By D4WNO77 in forum Access Tables & Databases
    Replies: 2
    Last Post: 07-16-2012, 09:55 AM
  4. Error 75 File/Path access error, sometimes Error 1004
    By smokebreak in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 02-16-2011, 02:35 PM
  5. Error Handling - On Error GoTo doesn't trap error successfully
    By David in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-16-2006, 02:10 PM

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