+ Reply to Thread
Results 1 to 9 of 9

Rare bug when copy pasting picture from 1 workbook to another

  1. #1
    Registered User
    Join Date
    01-03-2015
    Location
    Europe
    MS-Off Ver
    2013
    Posts
    40

    Rare bug when copy pasting picture from 1 workbook to another

    Hi all,

    I occasionally run into a bug when copy pasting picture from 1 workbook to another

    Currently i use this solution, I paste in a newly created worksheet in a loop, so for each loop the picture is pasted to the new worksheet. It does work in 99% of time but sometimes the last line WS_Temp.paste doesn't work. When I return from error handling back to the line and resume it, it works.

    Please Login or Register  to view this content.
    before I have used this solution with the same results:

    Please Login or Register  to view this content.
    Would you please know some workaround or solution for this?

    Many thanks!

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,523

    Re: Rare bug when copy pasting picture from 1 workbook to another

    You should show how you have dimmed the variables.

    Your title reads "...from 1 workbook to another ", you don't mention workbooks in the question.
    Last edited by davesexcel; 01-15-2018 at 09:15 AM.

  3. #3
    Registered User
    Join Date
    01-03-2015
    Location
    Europe
    MS-Off Ver
    2013
    Posts
    40

    Re: Rare bug when copy pasting picture from 1 workbook to another

    Hi Dave,

    my apologies. Here it is:

    Please Login or Register  to view this content.
    Setting:
    Please Login or Register  to view this content.


    At the end of each loop I have:

    Please Login or Register  to view this content.
    Last edited by Andrew87..; 01-15-2018 at 09:37 AM.

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,523

    Re: Rare bug when copy pasting picture from 1 workbook to another

    I see
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Does the code know what ".Range("B2")" is? Or maybe it thinks it is a different sheet? You have a period before range, this would mean you have qualified the range with a sheet.
    for example:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-03-2015
    Location
    Europe
    MS-Off Ver
    2013
    Posts
    40

    Re: Rare bug when copy pasting picture from 1 workbook to another

    Hi,

    that was my previous solution and you are indeed right about that, I had an incorrect reference there, however my current solution is:


    Please Login or Register  to view this content.
    Here it should be clear.

  6. #6
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,523

    Re: Rare bug when copy pasting picture from 1 workbook to another

    I thought my previous post was the solution, if not, you may have to supply a sample workbook ....

  7. #7
    Registered User
    Join Date
    01-03-2015
    Location
    Europe
    MS-Off Ver
    2013
    Posts
    40

    Re: Rare bug when copy pasting picture from 1 workbook to another

    Hi,

    got it thank you, so I implemented your solution now:

    Please Login or Register  to view this content.
    I have tested it on my range in loop, out of 150 it failed twice. I suspect it must have something to do with pasting the picture from 1 sheet (another workbook) to another. After the bug simple resume continues the code without any issue. I think some delay could potentially fix it, or i will try to copy it only once and keep it on the temp workbook during all loops just manipulating the location each time.

    The error I forgot to mention from errorhandler is:

    Paste method of Worksheet class failed 1004
    Last edited by Andrew87..; 01-15-2018 at 12:48 PM.

  8. #8
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,523

    Re: Rare bug when copy pasting picture from 1 workbook to another

    Just an FYI, if you have a picture in a range, you can copy the range and the picture will paste with it.
    -
    -

    PictA1E7.JPG

    -
    -
    The code will copy the range, including the picture and paste it where you need to.

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    01-03-2015
    Location
    Europe
    MS-Off Ver
    2013
    Posts
    40

    Re: Rare bug when copy pasting picture from 1 workbook to another

    Hi,

    thanks for this tip. For now I have solved it by loop and count of shapes within the sheet. While testing it the paste failed on 3 occasions but on the 2nd attempt in the loop it worked so I think this is an ok workaround for what seems to be a bug.

    Please Login or Register  to view this content.

+ 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. [SOLVED] How to copy from source workbook and pasting at first empty row in destination workbook
    By taylorsm in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-29-2017, 10:20 AM
  2. [SOLVED] Copy header picture from one workbook to another
    By ArnolddG in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-07-2015, 02:28 PM
  3. Ease of Copy Pasting from one workbook to other.
    By shashu999 in forum Excel General
    Replies: 4
    Last Post: 04-04-2014, 05:16 AM
  4. Macro for copying charts to another workbook and pasting as an picture?
    By chuggins143 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-07-2013, 01:41 AM
  5. Move/Copy the picture from excel workbook to MS word
    By kate.middleton1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-17-2012, 10:15 AM
  6. Problem when copy pasting a picture from sheet to sheet
    By leugu in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-15-2011, 04:07 AM
  7. Replies: 0
    Last Post: 08-11-2011, 01:23 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