+ Reply to Thread
Results 1 to 10 of 10

Copy-Paste Shapes from one worksheet to another using Clipboard - Excel VBA

  1. #1
    Forum Contributor
    Join Date
    03-07-2006
    Location
    India
    MS-Off Ver
    MSOffice 365 Professional 64 bit
    Posts
    108

    Copy-Paste Shapes from one worksheet to another using Clipboard - Excel VBA

    I am using Windows 10 Enterprise 64 bit, Office 2016 Pro 64 bit. I am trying to copy 2 shapes from one worksheet to another worksheet.


    The following API code works sometimes, but most times it shoots an Error 1004 for Copy or Paste (Clipboard timing issue). I have tried using different solutions e.g. Timer, Wait, API etc., but seem slow and buggy most of the times!
    Also i am trying to paste the images on opposite ends of each merged cell. I have also attached a sample file for inspection.


    I don't remember but i read somewhere that if i create separate copy and paste functions/procedures, then it might solve the issue, though not sure!


    Please Login or Register  to view this content.

    The API code:


    Please Login or Register  to view this content.

  2. #2
    Forum Expert BMV's Avatar
    Join Date
    01-13-2020
    Location
    St-Petersburg, Russia
    MS-Off Ver
    2013-2016
    Posts
    1,329

    Re: Copy-Paste Shapes from one worksheet to another using Clipboard - Excel VBA

    Why do you need use clipboard?
    Try to use
    Please Login or Register  to view this content.
    and function
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    03-07-2006
    Location
    India
    MS-Off Ver
    MSOffice 365 Professional 64 bit
    Posts
    108

    Re: Copy-Paste Shapes from one worksheet to another using Clipboard - Excel VBA

    Hi @BMV. Thanks for your reply.

    Your code seems to be working (w/o need of Clipboard functions) though pasting it erratically. Here is a screenshot:

    erratic.JPG

    How do i rectify the code so that it paste the 2 shapes correctly in the Left and Right corners of the merged cell?

  4. #4
    Forum Contributor
    Join Date
    03-07-2006
    Location
    India
    MS-Off Ver
    MSOffice 365 Professional 64 bit
    Posts
    108

    Re: Copy-Paste Shapes from one worksheet to another using Clipboard - Excel VBA

    BTW on subsequent runs, the code crashes my excel. I think due to the fact that the Clipboard may be full!

  5. #5
    Forum Expert BMV's Avatar
    Join Date
    01-13-2020
    Location
    St-Petersburg, Russia
    MS-Off Ver
    2013-2016
    Posts
    1,329

    Re: Copy-Paste Shapes from one worksheet to another using Clipboard - Excel VBA

    This part must be corrected
    Please Login or Register  to view this content.
    Add Aligement parameter
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Last edited by BMV; 03-07-2020 at 03:39 PM.

  6. #6
    Forum Contributor
    Join Date
    03-07-2006
    Location
    India
    MS-Off Ver
    MSOffice 365 Professional 64 bit
    Posts
    108

    Re: Copy-Paste Shapes from one worksheet to another using Clipboard - Excel VBA

    Thanks @BMV. This works pretty fast even with the double `DoEvents`. I turned off Application.EnableEvents, Application.ScreenUpdating, Application.DisplayAlerts & Application.Calculation....and it still works pretty well!

    One Question: do we need to add "Application.CutCopyMode=False" to clear clipboard off too many shapes?
    :-)

  7. #7
    Forum Expert BMV's Avatar
    Join Date
    01-13-2020
    Location
    St-Petersburg, Russia
    MS-Off Ver
    2013-2016
    Posts
    1,329

    Re: Copy-Paste Shapes from one worksheet to another using Clipboard - Excel VBA

    junoon. to say the truth I forgot about CutCopyMode yesterday and it could be done before end of function. Speed of process will be the same.
    Last edited by BMV; 03-08-2020 at 12:56 AM.

  8. #8
    Forum Contributor
    Join Date
    03-07-2006
    Location
    India
    MS-Off Ver
    MSOffice 365 Professional 64 bit
    Posts
    108

    Re: Copy-Paste Shapes from one worksheet to another using Clipboard - Excel VBA

    No worries. Thanks.

    I came to know this is a known issue with many in Office 365 and Office 2016 Pro 64 bit. Hope Microsoft resolves this clipboard issue soon.

  9. #9
    Forum Expert BMV's Avatar
    Join Date
    01-13-2020
    Location
    St-Petersburg, Russia
    MS-Off Ver
    2013-2016
    Posts
    1,329

    Re: Copy-Paste Shapes from one worksheet to another using Clipboard - Excel VBA

    Quote Originally Posted by junoon View Post
    issue with many in Office 365 and Office 2016 Pro 64 bit.
    and other and I don't hope Microsoft fix it soon :-).

    One remark . As you can see function return reference to the copied object or false in the case of error. You can use object for move resize....
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    03-07-2006
    Location
    India
    MS-Off Ver
    MSOffice 365 Professional 64 bit
    Posts
    108

    Re: Copy-Paste Shapes from one worksheet to another using Clipboard - Excel VBA

    Quote Originally Posted by BMV View Post
    and other and I don't hope Microsoft fix it soon :-).

    One remark . As you can see function return reference to the copied object or false in the case of error. You can use object for move resize....
    Please Login or Register  to view this content.
    Yes, indeed. This i find very useful. Thanks once again. :-)

+ 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. Clipboard, Copy, Cut & Paste Problem in Excel 2016
    By cew75 in forum Excel General
    Replies: 1
    Last Post: 11-02-2017, 04:36 PM
  2. [SOLVED] ws.Paste method fails after lots of copy-paste of shapes
    By bagullo in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-15-2015, 03:00 AM
  3. Replies: 0
    Last Post: 09-10-2013, 08:31 PM
  4. Replies: 3
    Last Post: 04-13-2012, 12:26 PM
  5. Copy and paste text in shapes to different worksheet
    By seabass in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-22-2010, 09:37 AM
  6. unable to copy/paste in excel once clipboard becomes full
    By sengtavanfatsura via OfficeKB.com in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 05-22-2006, 04:55 PM
  7. [SOLVED] Unable to copy/paste in Excel once clipboard gets full
    By Sean via OfficeKB.com in forum Excel General
    Replies: 0
    Last Post: 04-26-2006, 06:50 PM

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