'Putting graphic into UserForm in VBA

I am trying to put a graphic file into a UserForm Image in VBA. Using the code below

UserForm1.Image1.Picture = "d:\Missionary\Mexico\Daisy Marlene Olivares.bmp"

I get the error

"Compile Error: Type mismatch".

I know that the file path is correct. Modifying the code to the following

UserForm1.Image1.Picture = LoadPicture("d:\Missionary\Mexico\Daisy Marlene Olivares.bmp")

I get the error

"Compile Error: Sub or Function not defined"

I suspect that part of the reason for this error is because the image control is not ActiveX. Can anyone help?

vba


Solution 1:[1]

You need to reference OLE Automation for the LoadPicture function.

enter image description here

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1