+ Reply to Thread
Results 1 to 8 of 8

send image to image ctrl in userfrom using vba doesn't work

  1. #1
    Registered User
    Join Date
    01-09-2013
    Location
    Montreal, Quebec, Cnada
    MS-Off Ver
    Office 365 MSO 64 bits (16.0.12130.20272)
    Posts
    9

    Post send image to image ctrl in userfrom using vba doesn't work

    I am trying to find a way to display images, typically jpg files, into a ctrl in a userform in excell using vba. (using office365 64bits)

    I have tried using the loadpicture function :

    Please Login or Register  to view this content.
    but I get this error message : Run-Time error -2147418113 (8000fffff) : Method LoadPicture of object _Application failed

    And I also tried assigning the file directly without using the function :
    Please Login or Register  to view this content.
    but I get a filetype mismatch error


    Although I am not shure, it looks like the loadpicture() function maybe did work in previous excel versions.

    I have search everywhere to get an answer as to why it doesn not work and I found the 2 following answers :

    1. You can't use the LoadPicture method to set the Picture property of an image control. This method works with ActiveX controls only. To set the Picture property of an image control, simply assign to it a string specifying the file name and path of the desired graphic.

    2. VBA will not allow assignment of bitmap handles at runtime using LoadPicture() to ANY object that has a .Picture property.

    Yet, I find people in youtube that shows step by step procedure that does not work for me and for many others since I found many people looking to solve that problem.

    anyhelp would be greatly appreciated,
    Thank you
    Last edited by zsylvainz; 11-04-2019 at 10:50 AM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: send image to image ctrl in userfrom using vba doesn't work

    Hello zsylvainz,

    In the VB Editor, click the Drop Down Arrow on the Project/Library ComboBox. You should see stdOLE listed
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    01-09-2013
    Location
    Montreal, Quebec, Cnada
    MS-Off Ver
    Office 365 MSO 64 bits (16.0.12130.20272)
    Posts
    9

    Re: send image to image ctrl in userfrom using vba doesn't work

    in the VBA editor, I don't see : "Drop Down Arrow on the Project/Library ComboBox. You should see stdOLE listed"

    Did you mean : Tools > Reference > stdOLE ?

    If this is what you meant, there is no "stdOLE" in the list.


    In Tools > Reference, I found "OLE Automation" and then tried running my function again and got the same error message as before.

    Please note : I am not using VisualBasic but Excel VBA editor. If I say that it is because I did not find any Project/Library Combobox.

    Thanks for your help, I will be waiting for another suggestion from you if you have other suggestions
    ZsylvainZ

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,432

    Re: send image to image ctrl in userfrom using vba doesn't work

    .
    It is difficult to determine without having your workbook here ... however, I believe the issue is with the path used to select the image

    Your path : Me.image1.Picture = LoadPicture("E:\desktop\anyimage.jpg") is missing the beginning ...


    E:\Users\YourComputerNameHere\Desktop\anyimage.jpg"


    Replace 'YourComputerNameHere' with the name of your computer. For example, when I log on to my computer the start up screen shows

    "Welcome My". My computer's name is : My

  5. #5
    Registered User
    Join Date
    01-09-2013
    Location
    Montreal, Quebec, Cnada
    MS-Off Ver
    Office 365 MSO 64 bits (16.0.12130.20272)
    Posts
    9

    Re: send image to image ctrl in userfrom using vba doesn't work

    Thank you Logit for your help. Unfortunately, the path is for certain the right one. I am 100% certain of this. Plus I did use : RightClic on the file > property > Security > then copied the object name before pasting it

    But you are right about the fact that destop should usually be in user folder ..... but I shortened the path in my text for clarity purpose. In my case, all my user folders (Desktop, document, picure, music....) are in folder E:\Myname\.... In Other words : E:\Myname\desktop\anyimage.jpg

    Thanks for the help but for shure the problem is not the path. Also please understand I also did try shorter paths and other images on other drives. I also tried several different size jpg and bmp files.
    Plus altough not an expert at programming, I have been programming VBA for over 15 years for my own personal use. I also used to be a computer technician for about 5 years and an aircraft electronic technician in my early days. If I am saying that, it is because I understand where your coming from since I also help a lot of people with their computers problems around me and I would also probably doubt the user. it is only to confort you that the path is something I double and triple checked.

    Thank you and I hope I did not offend you, simply wanted to reassure you about my assurance this is not the problem.
    Last edited by zsylvainz; 11-05-2019 at 04:13 AM.

  6. #6
    Registered User
    Join Date
    01-09-2013
    Location
    Montreal, Quebec, Cnada
    MS-Off Ver
    Office 365 MSO 64 bits (16.0.12130.20272)
    Posts
    9

    Re: send image to image ctrl in userfrom using vba doesn't work

    In excel, I inserted a New UserForm and added a command button and a image ctrl on the form. So the form has only 2 controls.

    The code :

    Please Login or Register  to view this content.

    and the error message : "Run-Time error -2147418113 (8000fffff) : Method LoadPicture of object _Application failed"

    PLEASE HELP

  7. #7
    Registered User
    Join Date
    01-09-2013
    Location
    Montreal, Quebec, Cnada
    MS-Off Ver
    Office 365 MSO 64 bits (16.0.12130.20272)
    Posts
    9

    Re: send image to image ctrl in userfrom using vba doesn't work

    You were right Leith Ross. I thought your answer was the right one so inspired from your answer which was 99.9% correct, here is precisely what happened with me to solve my problem.

    in excel in the VBA editor, I selected : Tools > Reference > and added "OLE Automation" as a reference
    OLE Automation" is located in the following file on my system : c:\windows\Sytem32\stdole2.tlb

    Now, since you told me to look for stdole, I did try to browse to that but would it not add to available references, I tried stdole32.dll, stdole.dll, stdole32.tlb

    So I though that stdole2.tlb was probably a newer version so I opened the object browser and selected "stdole" in the library combobox. At the bottom, I saw the library is named "stdole" even if it is located in file stdole2.tlb, so I finally understood what you meant. I also noticed there was the "loadpicture" function as a member of stdole. So I was excited.

    The initial problem comes from the fact that "OLE Automation" was not selected as a reference, and therefore stdole was also missing when I first looked for it in the object browser.

    I did try my function again and still gave me the error message. so I though I need to reboot the computer to make shure.

    Shure enough, after rebooting, everything works as supposed to.

    THANK YOU Leith Ross a thousand times ....thanks, thanks, thanks...
    Last edited by zsylvainz; 11-05-2019 at 04:22 AM.

  8. #8
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,432

    Re: send image to image ctrl in userfrom using vba doesn't work

    .
    Glad you found your answer.

    Cheers !

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA to cut image file path from word bookmark and replace with inserted image
    By JayRay1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-11-2018, 07:31 PM
  2. [SOLVED] Using a Userform to Browse image file then paste selected image to sheet?
    By matrixpom in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-05-2015, 05:42 PM
  3. Problem with image File Link in Cell not opening image for preview
    By Orada in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-24-2015, 09:33 AM
  4. [SOLVED] How to apply Image borders to an image that my excel vba userform pastes in a word doc?
    By CaptainCool in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-11-2014, 05:40 PM
  5. [SOLVED] data validadion doesn't work when worksheet is populated from userfrom??????
    By ciapul12 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-22-2014, 03:53 PM
  6. [SOLVED] VBA to send embedded image in email body- NOT USING THE ORGINAL IMAGE SOURCE
    By Coreyusa in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-27-2013, 06:48 PM
  7. why does ctrl+v paste an image of the screen?
    By GingerMagician in forum Excel General
    Replies: 0
    Last Post: 04-16-2006, 10:25 AM

Tags for this Thread

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