+ Reply to Thread
Results 1 to 18 of 18

Runtime Error 481 Invalid Picture

  1. #1
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Runtime Error 481 Invalid Picture

    I have a spreadsheet with a user form displaying different graphs based on a combo box user selection. This is based on John Walkenbach's solution and uses this code.

    Please Login or Register  to view this content.
    This works perfectly in Excel 2007, however when the same file is run in Excel 2010, I get frequent 'Runtime Error 481 Invalid Picture' errors.

    Looking at Microsoft's site, there is a suggestion that I should use a BMP rather than a GIF file format (as this is a known Microsoft problem). Having amended the VBA accordingly, this made NO DIFFERENCE and the errors still happen.

    I also came across a site suggesting a 'HotFix' using an updated version of a file called 'mscomctl.OCX'. Having tried this, again, it makes no difference.

    I can save my file in Excel 2010, and reopen it in Excel 2007 and the errors don't occur.

    Has anyone come across this problem and found a successful resolution.

    Many thanks...

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Runtime Error 481 Invalid Picture

    That test code works fine for me in xl2010.

    Try some tests.

    First try using the LoadPicture command on a gif file that you know is valid.
    Then try the ChartExport and use paint to check the file produced is valid.

    Also try jpg rather than bmp.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Runtime Error 481 Invalid Picture

    Hi Andy

    The problem seems to be related to the graph export. As I say, in 2010 the Runtime Error happens seems to happen because the exported graph generates a file that is 0kb, whereas running the same spreadsheet in 2007 there are no problems whatsoever.

    When this problem was first reported (the file was created in 2007) but the end user is running 2010, I recreated all the graphs in 2010, however the problem still exists and seems to be unique to 2010.

    I've tried numerous other file formats including jpg, but it makes absolutely no difference, so I assume this must be an excel 2010 or a visual basic bug?

    Any other thoughts?

  4. #4
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Runtime Error 481 Invalid Picture

    I should point out that some of the exported graphs generate a 0kb file, whilst others are fine. All the code is doing each time is exporting and overwriting the previous version of the file, so this makes little sense to me as to why some files are fine and others are not...

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Runtime Error 481 Invalid Picture

    I wonder whether the loadpicture is executing before the export finishes.

    try stepping through the code and only execute the loadpicture line once you can see that the file size of the exporting file is not 0kb. If this is the case then you need to add a delay to the code.

  6. #6
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Runtime Error 481 Invalid Picture

    Hi Andy

    I'm afraid I'm a VBA Virgin, how would I go about doing this?

  7. #7
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Runtime Error 481 Invalid Picture

    Alter the code slightly.

    Please Login or Register  to view this content.
    The stop command will pause the running program and take you to the vbe.
    Use an file explorer window to check the file size of the exported file.

    then use F5 to continue code running

  8. #8
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Runtime Error 481 Invalid Picture

    Hi Andy

    OK, Instance 1, where I get the runtime error on the first chart that is supposed to load, at the 'Stop' point a file of 8kb is generated but I normally get the Runtime Error 481 before it can display the first graph in the series.

    I would anticipate that if I again, recreate this 'first graph' then the error would go away, but it seems as though it can still come back again...

    Instance 2, where the graph that errors is the 6th one in the series, at the point where 'Stop' is initiated, the file size of the exported graph is 0kb, hence there error.

    If I then go on to click F5, I get a Runtime Error 424 - Object Required.

    Does this suggest anything?

  9. #9
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Runtime Error 481 Invalid Picture

    Can you post example workbook that illustrates the problem.

    As I said the code and my example in xl2010 works fine.

  10. #10
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Runtime Error 481 Invalid Picture

    Can I PM this to you as the data is sensitive?

  11. #11
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Runtime Error 481 Invalid Picture

    If it quciker that making example then yes.

  12. #12
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Runtime Error 481 Invalid Picture

    I can generate the error as described.

    I unhide the sheet with the charts on it. selected cell A1. re hide the sheet and the cyan button worked as expected.

    Can you try that?

  13. #13
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Runtime Error 481 Invalid Picture

    Bizarre, yes I can confirm that this works!

    The charts for the pink circle are on a sheet which isn't currently hidden, so I tried clicking in call A1 for this sheet and this didn't work for this set. I also tried hiding the sheet but again it made no difference?

    The error only occurs for the pink circle when you reach the 9th item in the list...

  14. #14
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Runtime Error 481 Invalid Picture

    Try this mod.

    Please Login or Register  to view this content.
    It makes the sheet with the charts on visible perform exporting it.

  15. #15
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Runtime Error 481 Invalid Picture

    Hi Andy

    Thanks for this, it seems to fix the cyan button problem, i.e. the hidden sheet, but not the pink button, i.e. the sheet that isn't hidden. I still get the Runtime 481 Error on that one from the start now, rather than from the 9th chart? Does that make any sense?

  16. #16
    Registered User
    Join Date
    04-28-2012
    Location
    Charlotte, NC
    MS-Off Ver
    Excel 2003, 07 & 10, 16
    Posts
    26

    Re: Runtime Error 481 Invalid Picture

    Not sure if you are still dealing with this, but I leveraged off of Walkenbach's macro as well. I've received the same error.

    I was re-sizing the Chart on my worksheet and I think I expanded the width / height of the chart too much and it wasn't able to "load" onto the UF.

    Once I went back and made the Chart on my ws smaller, it worked (so far...) in my Macro.

  17. #17
    Registered User
    Join Date
    06-28-2011
    Location
    Bristol, UK
    MS-Off Ver
    Excel 2010, 2013, 2016, 365
    Posts
    79

    Re: Runtime Error 481 Invalid Picture

    Has anyone been able to find a fix for this yet? I am having exactly the same problem and it's becoming quite embarrassing as it's doing it in a professional tool....

  18. #18
    Registered User
    Join Date
    06-28-2011
    Location
    Bristol, UK
    MS-Off Ver
    Excel 2010, 2013, 2016, 365
    Posts
    79

    Re: Runtime Error 481 Invalid Picture

    I just answered my own question - programmatically select the chart object in the worksheet before copying it. This seems to fix the issue for now.

    Solution found here: http://www.vbaexpress.com/forum/show...-chart-s-error

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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