views:

174

answers:

1

Hi,

I have an Excel 2007 Worksheet with many buttons and labels that act as menu options (i.e. user clicks the buttons, labels with images) and is presented with forms, or some thing else.

These images / icons for the buttons and labels are loaded in VBA by assigning the Picture property of the Control and calling LoadPicture() method with the full image file path as parameter, like So.

   With SomeFormObject
        .cmdOpenFile.Picture = LoadPicture("F:\projectname\images\fileopen.BMP")
   End With

This method of loading images for buttons, other controls is causing 2 issues.

1) It creates a dependency on the image files and physical location for every user, so if a user does not have the drive mapped and files present, the VBA fails with runtime error of file or path not found.
2) The app gets very slow if the images are on a shared drive (which is the case)

I want to eliminate both issues and somehow load icons, images into control internally, without any external dependencies on external image files.

What is the best way to achieve this in Excel 2007 VBA?

I could not file any Visual Basic 6.0 / Visual Studio style "Resource File Editor" / feature with which to accomplish this.

Please advice! thank you

-Shiva @ mycodetrip.com

A: 
marg
Thanks for the code snippet and feedback Marg! You are right, the approach of keeping images in a sheet and then loading it does see messy and clunky.W.r.t. using mapped network drive, there is a significant delay for users in remote physical locations. I am talking 2, 3 seconds for loading 20 ui icons / images locally, vs 2 minutes or so for a user in a location across the country. that's what i am trying to avoid, so keeping images in mapped drive is out of question.i guess i could redistribute images with app so they load locally, but that build the dependency on images being present.. :(
Shiva