LoadPicture not showing as function in Excel 2013 VBA

twilsonco

New Member
Joined
Dec 25, 2012
Messages
33
I'm making a userform to run on both Mac and PC. The form does stuff with pictures, and since certain functions don't exist in the Mac VBA, I identify which platform is running and the proper code is used.

However, when trying to use LoadPicture() to put an image in the userform image control in Windows Excel 2013, I get the same compiler error as when I tried to use it in Mac Excel 2011, "Compiler Error: Sub or Function not defined"

This is strange, as I'm using the function based on syntax at the microsoft website. It's a known issue that LoadPicture doesn't work in Mac, but why should this be happening with the windows version? Did they remove LoadPicture in Office 2013 or replace it with something else?

I know I can to get around this with the PastePicture method by Stephen Bullen, but I'd like to avoid having to install custom stuff.

Here's the line of code I'm using, where Picture1 is a string containing the full path and filename of the picture to be loaded, and pictureWindow is the image control in the userform:

Code:
pictureWindow.Picture = LoadPicture(Picture1)

After the compiler error is thrown, "LoadPicture" is highlighted.

Any help is appreciated.

Thanks,

Tim
******** type="cosymantecnisbfw" cotype="cs" id="SILOBFWOBJECTID" style="width: 0px; height: 0px; display: block;">******** type="cosymantecnisbfw" cotype="cs" id="SILOBFWOBJECTID" style="width: 0px; height: 0px; display: block;"></object>
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
LoadPicture is still available in 2013 (part of the stdole library). Are you using 32 or 64bit Office as a matter of interest?
 
Upvote 0
I'm using 64bit Excel 2013. Is there a specific references package (or whatever you'd call it, template library maybe) that I need to enable? I have 4 enabled, including "OLE Automation," whose file is stdole2.tlb.



******** type="cosymantecnisbfw" cotype="cs" id="SILOBFWOBJECTID" style="width: 0px; height: 0px; display: block;"></object>
 
Upvote 0
See the custom load picture function in the examples on this page
Images on Custom Ribbon controls in Excel 2007-2013

On a Mac loadpicture is not working

That does look pretty cool, but I'm just curious why my Windows machine doesn't think that the LoadPicture function exists... I've already finished a workaround for those running Mac.******** type="cosymantecnisbfw" cotype="cs" id="SILOBFWOBJECTID" style="width: 0px; height: 0px; display: block;"></object>
 
Upvote 0
Maybe, you created that workbook with your code on a Mac computer. If it is true then you have not a reference to OLE Automation library. Please, add this reference to your VBA project using Tools/References menu of VBA Editor.
 
Upvote 0
I can only test it in 32 bit and it is working OK there, I see no need to install a 64 bit Office.

I like to use the custom function because I can load png files also


I'm using 64bit Excel 2013. Is there a specific references package (or whatever you'd call it, template library maybe) that I need to enable? I have 4 enabled, including "OLE Automation," whose file is stdole2.tlb.



******** type="cosymantecnisbfw" cotype="cs" id="SILOBFWOBJECTID" style="width: 0px; height: 0px; display: block;"></object>
 
Upvote 0
I tried using LoadPictureGDI, but I need to modify it to work on 64bit. Don't suppose you know of anyone who's already done that?******** type="cosymantecnisbfw" cotype="cs" id="SILOBFWOBJECTID" style="width: 0px; height: 0px; display: block;"></object>
 
Upvote 0
Download the example files here, the function is also working in 64 bit Excel
Images on Custom Ribbon controls in Excel 2007-2013



I tried using LoadPictureGDI, but I need to modify it to work on 64bit. Don't suppose you know of anyone who's already done that?******** type="cosymantecnisbfw" cotype="cs" id="SILOBFWOBJECTID" style="width: 0px; height: 0px; display: block;"></object>
 
Upvote 0
I see! Cool, just need to test it out! Thanks for the help. I'll come back here crying if I have more problems, per the usual...
 
Upvote 0

Forum statistics

Threads
1,215,525
Messages
6,125,325
Members
449,218
Latest member
Excel Master

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top