PDA

View Full Version : Solved: Background Images On Excel



Derek
10-26-2006, 07:22 AM
Hi Folks
I wonder if you can help me with this issue.
I have a fairly elaborate excel programme which, using vba, opens a background image each time a worksheet is open (it helps give a corporate feel and less of an excel feel to the programme). We use code to do this so that the image is only present when a worksheet is open, therefore limitimg system resource usage as there can be several sheets to a workbook and several workbooks open at any one time. (therefore if there are 4 workbooks open at the same time, there are only 4 sheets with the background image rather 4 x the number of sheets per workbook)

However, as the image is tiled on each worksheet for the entire width and height of the sheet the image is actually loaded many many times. Is there any way via code that this image is only loaded in the top left of the sheet as this is the only area the user views as opposed to being tiled all over the sheet??

Thanks in advance

Derek

Bartek
10-26-2006, 12:33 PM
Hi,


However, as the image is tiled on each worksheet for the entire width and height of the sheet the image is actually loaded many many times. Is there any way via code that this image is only loaded in the top left of the sheet as this is the only area the user views as opposed to being tiled all over the sheet??
You do not specify what do you mean by "bacground image". If this an image inserted with Format > Sheet > Background? Or with VBA:
Sheet1.SetBackgroundPicture Filename:="image.jpg" In that case you cannot prevent the image to be tiled, however I do not think that Excel actually reads the image several times. It reads it once and then replicates, just like HTML browsers. Thus, it is unlikely that your system usage is affected by showing this background image, unless it is a very large file.

Derek
10-26-2006, 01:12 PM
Bartek
Thanks for taking the time out to reply.
You are correct. That is what I mean by "background image". Interesting to hear your view that it does not affect system resource. Maybe then I am on the wrong track but after several "movements" in and out of various worksheets/wprkbooks, we can get an error saying something like "set background picture failed - insufficient resource to display" and excel freezes. The image file is only about 50kb, but interestingly when you add the file as background it can add about 4mb to the size of the file, so I felt it possoble that it also would use up a chunk of system memory as well.

Maybe not, maybe back to the drawing board! :o)

Derek

MWE
10-26-2006, 03:49 PM
Excel "running out of resources" can have many sources (and most are bogus, i.e., the real problem often does not relate to the error message). I doubt that the problem you are encountering is really related to the image display. I have seen problems that were system memory dependent (ran on sys A with 512mB of RAM and not on sysB with 256 mB) and problems that seemed more related to the Excel version (2K vs 2003, etc). Excel should handle "insufficeint resources", but if Excel did precisely the things it should, what would William and the Gatettes have to work on ?

If you remove the display code, does the problem go away?

Bartek
10-27-2006, 12:31 AM
Hi,


The image file is only about 50kb, but interestingly when you add the file as background it can add about 4mb to the size of the file, so I felt it possoble that it also would use up a chunk of system memory as well.

I also noticed this problem with embedding background image. It seems that Excel converts any image to uncompressed true color bitmap, thus its impact on .xls fize size depends only on its resolution, not the the size of original gif ob jpg image. Your are probably inserting a 1280x1024 or similar scale image. This may indeed slow everything down a bit. Maybe the option is to resize the image, make a small tiled corporate logo etc.

thomaspatton
10-29-2006, 08:48 AM
Compress al your unused empty row and colummn dimensions to "zero". That way, you only need the one 1024x768 image, as the rest of the sheet will be hidden and it has nothing to tile it to.

Derek
11-01-2006, 03:19 PM
Thank you all for your input. I am away to try out all your suggestions. I will mark this as solved as I am certain all or some of these will help us.

Thanks again