+ Reply to Thread
Results 1 to 51 of 51

upload images in excel file

  1. #1
    Forum Contributor
    Join Date
    08-18-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    490

    upload images in excel file

    Hey guys,
    i need a small help.

    I need a code which would automatically upload images from C:\Users\Laptop\Desktop\picture in sheet "PRODUCT"
    In sheet "PRODUCT", range "A:A" i have list of product codes . So if the code name matches any file named with the same code in the above directory , then i would like to automatically fetch it in excel file.

    I have uploaded my excel file.
    Please have a look and let me know.

    Thank you
    Attached Files Attached Files

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: upload images in excel file

    I suggest you search for MyVB_polly (nickname), posted a similiar question and I think that might help you
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Forum Contributor
    Join Date
    08-18-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    490

    Re: upload images in excel file

    Hey Keebellah,

    Here is the code which i got from the thread which you mentioned. Thank you for it.
    Please Login or Register  to view this content.

    I have edited it . Here it is.
    Please Login or Register  to view this content.
    I am new to VBA and i dont have much knowledge about it.
    What else modification is required?

    Can you please help me

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: upload images in excel file

    But, what does it doe? Does it work?

  5. #5
    Forum Contributor
    Join Date
    08-18-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    490

    Re: upload images in excel file

    hey Keebellah,
    it does not do anything as of now. Probabbly I am doing it wrong.
    Also i forgot to mention, I am trying to insert the image in range T:T
    I have attached my workbook.

    Please do have a look and let me know.

    Thank you
    Attached Files Attached Files
    Last edited by anilpatni1234; 04-28-2019 at 07:04 AM.

  6. #6
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: upload images in excel file

    Have tried to go though the code step by step?
    Select the macro and press F8 and then go from line to line so you can see what it's doing.

  7. #7
    Forum Contributor
    Join Date
    08-18-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    490

    Re: upload images in excel file

    Hey Keebellah,

    I read the code and tried understanding it.

    I have modified the code but its still not working

    Please Login or Register  to view this content.
    Please do have a look

  8. #8
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: upload images in excel file

    Have tested line by line, troubleshooting is the most time consuming thing to do but you have to verify that the image file actually exists , is present, and is it a jpg file?
    Do you get an error message ?
    Remember that it’s your pc with your file location for the images

  9. #9
    Forum Contributor
    Join Date
    08-18-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    490

    Re: upload images in excel file

    Hey Keebellah,

    I have attached my workbook.
    Please check if i have written the code properly.
    Also i have attached a snap of the folder where images exists .
    Image name is "ak46" which is also present in range A1:A
    it is a jpg file

    please have a look
    Attached Images Attached Images
    Attached Files Attached Files

  10. #10
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: upload images in excel file

    I won't do much explaining but here's the working code
    You should have checked the value for lastRow
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    08-18-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    490

    Re: upload images in excel file

    Hey Keebellah,
    Thank you for helping me out.
    However I am sorry for the trouble which i m causing.

    I have pasted the above code in my excel file but still its not working.
    The image location is also correct. i am attaching the workbook also.
    It is not able to fetch the image somehow.
    Thank you

    Should i add a button and assign this code to it?
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by anilpatni1234; 04-28-2019 at 10:27 PM.

  12. #12
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: upload images in excel file

    Let's say it's your lack of experience and not knowing how to troubleshoot.
    Please Login or Register  to view this content.

    Please Login or Register  to view this content.

  13. #13
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: upload images in excel file

    I made some adjustments, copy the entire code and replace the whole code you have if your file.
    Threre is less margin for error this way


    Please Login or Register  to view this content.

  14. #14
    Forum Contributor
    Join Date
    08-18-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    490

    Re: upload images in excel file

    Hey Keebellah,

    This code is working perfectly . Thank you so much.
    I am trying my best to learn VBA. Hope I can be better with time.

    Also, is one modification possible?

    After the image is uploaded in the excel file, is it possible to enlarge the image if the user clicks or double clicks on the image ?

  15. #15
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: upload images in excel file

    Time and patience and imagination.
    Yes, but will have to think in the matter of a userform that opens and displays the image in a larger size.
    That will be quite some coding to do.

  16. #16
    Forum Contributor
    Join Date
    08-18-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    490

    Re: upload images in excel file

    Hey keebellah,
    Thank you for your help.
    This is the code which I got from internet. It does enlarge the picture.
    But the problem is that i need to assign the code indivisually to all the picture.
    Is it possible to modify this code so that the code gets auto applied to all the images which gets uploaded in excel sheet?
    Also the picture does not come in centre of the page. it comes in the side.

    Please do have a look
    Right now If i click an image its size increases
    I have uploaded my file . Also this the code which helped me enlarge the picture:
    Please Login or Register  to view this content.
    Attached Files Attached Files

  17. #17
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: upload images in excel file

    I'll check later today

  18. #18
    Forum Contributor
    Join Date
    08-18-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    490

    Re: upload images in excel file

    Sure,

    Thank you so much

  19. #19
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: upload images in excel file

    Okay, this is another way.
    Once the pictures are visible in column T, Right-Click mouse on the shapes name (Column A) to see the image in a userform
    With the mouse you can resize the userform
    Attached Files Attached Files

  20. #20
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: upload images in excel file

    Minor corrections were needed.
    Attached Files Attached Files

  21. #21
    Forum Contributor
    Join Date
    08-18-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    490

    Re: upload images in excel file

    Hey Keebellah,
    I am getting this error .
    I have attached the screenshot
    Attached Images Attached Images

  22. #22
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: upload images in excel file

    Which file are you using?

  23. #23
    Forum Contributor
    Join Date
    08-18-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    490

    Re: upload images in excel file

    i m using the file you uploaded in post #20

  24. #24
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: upload images in excel file

    Sorry, my mistake, thought I corrected that it's a line required for compatibility between 64 and 32 bit versions.
    Here's the same file, but corrected.
    Attached Files Attached Files

  25. #25
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: upload images in excel file

    And, is it working now?

  26. #26
    Forum Contributor
    Join Date
    08-18-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    490

    Re: upload images in excel file

    Yes Keebellah, it is working now.

    But i was just trying to edit the code .
    Instead of right clicking on Column A, I was trying to make it to column C. (Basically right click Column C to pop up the image)
    However I havent got any success.
    Here is the code which I tried to modify.

    Also I am trying to copy entire code and userform to my main excel file. (because this file was just to test. Now since its working i will paste it to my main file )

    Please Login or Register  to view this content.

  27. #27
    Forum Contributor
    Join Date
    08-18-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    490

    Re: upload images in excel file

    Hey Keebellah,
    I was just trying to copy paste entire code in a new excel file just to check if its working.
    I made the same userform as you made and copied all the code . However I am getting this error.
    Why is it showing me this error considering I have copied all the code?
    Attached Images Attached Images
    Attached Files Attached Files

  28. #28
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: upload images in excel file

    The userform has a Label1 in the top left that show's the image name, since it has no caption you don't see it.
    If you use column C then you need to check column A id it's empty

  29. #29
    Forum Contributor
    Join Date
    08-18-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    490

    Re: upload images in excel file

    Hey Keebellah,
    The problem is that I have freezed column A in my main file.
    This is to ensure that no user changes the data in column A once it has been entered.
    Here is the code which freezes block A

    I have uploaded my main file in which I will copy paste all the code and picture form. Please do have a look. Sheet "Product" Column A is freezed
    The username for the uploaded file is "test" and password is "test"
    Please Login or Register  to view this content.
    Attached Files Attached Files

  30. #30
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: upload images in excel file

    Here's the corrected file. And right-click Column C
    Hope this is it.
    Attached Files Attached Files

  31. #31
    Forum Contributor
    Join Date
    08-18-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    490

    Re: upload images in excel file

    Hey Keebellah,
    This file is working.
    Thank you so much.
    I will just try copying all these codes to my main file and let you know if there is any problem.
    But thank you so much.
    Thank you

  32. #32
    Forum Contributor
    Join Date
    08-18-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    490

    Re: upload images in excel file

    Hey Keebellah,

    One minor problem again. Sorry.

    I already have this 2 codes in sheet "Product"
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    So it is not letting me compile with your code:

    Please Login or Register  to view this content.
    Attached Images Attached Images

  33. #33
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: upload images in excel file

    The eror says it, Ambiguous modue
    You have to integrate it into one.
    Option Explicit goes on the top ONCE only.

  34. #34
    Forum Contributor
    Join Date
    08-18-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    490

    Re: upload images in excel file

    Hey Keebellah,

    Is this correct?

    Currently i dont see any error , Also it is abe to fetch the image .
    But still I would like to verify if i have done it right
    Please Login or Register  to view this content.

  35. #35
    Forum Contributor
    Join Date
    08-18-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    490

    Re: upload images in excel file

    Hey Keebellah,
    everything is working except this (the screenshot attached).
    This code was to track what changes are made in workbook and by which user.
    I have attached my workbook as well.
    USername is test
    password is test
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by anilpatni1234; 04-30-2019 at 06:16 AM.

  36. #36
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: upload images in excel file

    The errro saiys it variable undefined, so.... define the variable.

  37. #37
    Forum Contributor
    Join Date
    08-18-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    490

    Re: upload images in excel file

    Hey Keebellah,
    The code use to work before.

    Its only when i insert this code that it creates problem''
    The code works perfectly if i dont enter the below code in This Workbook.

    Can you please have a look once?

    Please Login or Register  to view this content.

  38. #38
    Forum Contributor
    Join Date
    08-18-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    490

    Re: upload images in excel file

    I tried but I am not able to compile all the codes together .
    Somewhere is wrong which I am not able to troubleshoot.

    The code which I combined in Post #34 is able to fetch the picture but does not let the image expand. (by right clicking column C)
    So there is a error which also I am unable to rectify. Sorry for the trouble.

    Also This Workbook codes arent merging together.

    Please help me
    Last edited by anilpatni1234; 04-30-2019 at 08:54 AM.

  39. #39
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: upload images in excel file

    You say all worked before, wel my file worked fine until you started inserting your code again, but you do not follow the VBA rules and restrictions.
    You inserted code in places it's not allowed that is exactly the error message I get now when I open the file Billll.xlsm you attached

    You removed the Before_RightClick form the PRODUCT sheet, well.
    Since you are messing with the code it doesn't work anymore. so why do you want help if you change it when it works?
    I am not going to waste anymore time on this.
    Attached Images Attached Images

  40. #40
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: upload images in excel file

    I corrected the dim error but the rest is your responsibility

    Happy clding
    Attached Files Attached Files

  41. #41
    Forum Contributor
    Join Date
    08-18-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    490

    Re: upload images in excel file

    Hey Keebellah,
    Sorry for all the trouble.
    I dont have much knowledge in VBA which has caused so much trouble.
    Sorry.

    But here is the file which you corrected in Post #30.
    Everything works till here until I start merging codes.

    Thank you.
    Attached Files Attached Files

  42. #42
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: upload images in excel file

    This file works for the images the right click works.
    You have many vba modules that are empty, I removed them since they serve no purpose.
    For the rest, I have no idea what you are doing with the other things so I don't think I can help you.
    I have no idea what the rest does.
    Attached Files Attached Files

  43. #43
    Forum Contributor
    Join Date
    08-18-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    490

    Re: upload images in excel file

    Hey Keebellah,

    Thank you so much.
    I will try understand and sort it out.
    But thank you so much for your time and efforts till now.
    THAN YOU

  44. #44
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: upload images in excel file

    If you explain the other modules you have...
    Events can be placed together but you need to identity them correctly so that they don't get in the way of other event triggers.\Worksheet_Selection Change are not loose modules like you have one or two.
    That is incorrect programming

  45. #45
    Forum Contributor
    Join Date
    08-18-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    490

    Re: upload images in excel file

    Hey Keebellah,
    I took a little break and started off freshly.

    I arranged all the codes together and its working as of now.
    I was just placing the codes wrongly as you had mentioned.

    One problem I am facing now is that :

    In sheet PRODUCT , cell A16 , i entered "ak79" and after that in column T it shows "NO IMAGE FOUND"
    This is because I dont have image in the assigned folder.

    By seeing "NO IMAGE FOUND" , I would naturally go to the folder and paste a image with name AK79

    Now what I want is that excel VBA detect that image named AK79 is available now in the folder, so it naturally updates from "NO IMAGE AVAILABLE " to showing the image .
    Attached Files Attached Files

  46. #46
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: upload images in excel file

    After you add the image, in the file, you select the cell with the image and refresh it.
    Another way way it to add a macro that updates the sheet every time it's activated or only when the workbook is opened.

  47. #47
    Forum Contributor
    Join Date
    08-18-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    490

    Re: upload images in excel file

    Hey Keebellah,

    Sure .

    It would be better that i add a macro that updates a sheet everytime its activated.

    So i will have to use this right?
    Please Login or Register  to view this content.
    But what do i enter in between the 2 of them ?

  48. #48
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: upload images in excel file

    You should learn to clean you VBA modules and organize them, it will help you to keep better track of your code and avoid chaos.
    I added a button to your sheet and also it is triggered when you activate the sheet.
    If you don't want it to happen every time lust remove the macro Private Sub Worksheet_Active
    Attached Files Attached Files

  49. #49
    Forum Contributor
    Join Date
    08-18-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    490

    Re: upload images in excel file

    Sure,
    Thank you so much.
    I will clean up the file.
    But thank you so much for all the help.

    I am infact very motivated to learn more about VBA. So i am reading about it on the internet everyday.

    Thank you for the help and the patience.
    Thanks

  50. #50
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: upload images in excel file

    Minor correction to avoid that macro runs on the wrong sheet
    All you really need is time and patience and you'll get there.
    Try reading the lines of code as you would a book, line by line and think of what it's doing.

    The same way to program

    You start with if a is this then do that else if b is something else do something else otherwise do this etc etc.
    The problem is the syntax, but try and keep your code simple and where possible reuse it for other things so it's easy to maintain.
    Try adding the option to select the folder with a macro instead of storing it in a constant
    Wll make it easier to maintain
    Attached Files Attached Files

  51. #51
    Forum Contributor
    Join Date
    08-18-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    490

    Re: upload images in excel file

    Sure Keebelah,

    Thank you for all the help.

    Yes I am trying my best. Hopefully i will be able to learn it soon.
    Thank you again for the help and motivation

+ 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. Upload Excel file PowerPivot
    By annlee in forum Excel General
    Replies: 1
    Last Post: 02-23-2017, 09:45 AM
  2. how do i upload an excel file to the forum
    By dmcgov in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-27-2015, 12:29 PM
  3. Choosing a file to upload on IE with Excel VBA?
    By dmasters4919 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-11-2015, 11:37 AM
  4. Upload a Excel file to a SharePoint
    By sur in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-10-2012, 10:54 PM
  5. Bulk upload images using excel
    By TimothyBateman in forum Excel General
    Replies: 0
    Last Post: 05-10-2012, 07:19 PM
  6. upload excel file into sql server
    By vic pahilan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-04-2005, 07:35 AM
  7. Upload Excel DIF file to AS400
    By GregR in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-25-2005, 12:05 PM

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