+ Reply to Thread
Results 1 to 4 of 4

Set image as background from folder based on value

  1. #1
    Registered User
    Join Date
    02-08-2023
    Location
    Germany
    MS-Off Ver
    365
    Posts
    80

    Set image as background from folder based on value

    Hello,
    I already have a working set of subs to display an image in a folder and it randomizes a new image every few seconds.

    But what I would like is to stop this sub when a specific cell has a value, and that value is retrieved in VBA to display images from a folder .
    For example, I have different flowers, with images in their own folders.
    When A1 displays the name of a flower, I would like to vlookup the path written in a table and it uses it to display the images of that flower in its folder.

    I will provide what I already have working, which shows all the images in a single folder.

    Please Login or Register  to view this content.
    It is not me who wrote this code, and I vaguely understand it. What I am asking is that if someone understands it, how can I use it to make a simple sub to display images by interval of 2sec like here, from a specific folder, that is retrieved in a table with the path written when A1 displays the name of that folder.

    I tried this, but it's not working (although no error):

    Please Login or Register  to view this content.
    Last edited by Soraka; 05-15-2023 at 08:30 AM.

  2. #2
    Registered User
    Join Date
    02-08-2023
    Location
    Germany
    MS-Off Ver
    365
    Posts
    80

    Re: Set image as background from folder based on value

    I am making a little progress
    I created a Public As Boolean to pause and resume the main background images.
    Now I need to figure out the rest

    Here is what I did so far:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    So whenever I open the workbook, it will shuffle all the images from the big folder, because the mainbg is set as True and it opens the 2 subs upon opening the excel file.

    But then I have this function in a cell:
    =IF(W4="*Yes*",BackGround(),"")

    Whenever W4 displays Yes, I want the 2 subs to stop shuffling through the big folder with all the images, and I want images from another folder to be displayed randomly.
    So I managed to stop the shuffling of the images of the big folder by starting this sub here:

    Please Login or Register  to view this content.
    I now need to figure out how to display on loop at random images from a folder (which the path is written in a cell in the spreadsheet).
    Last edited by Soraka; 05-15-2023 at 08:29 AM.

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,724

    Re: Set image as background from folder based on value

    Please change QUOTE tags to CODE tags. Thank you.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  4. #4
    Registered User
    Join Date
    02-08-2023
    Location
    Germany
    MS-Off Ver
    365
    Posts
    80

    Re: Set image as background from folder based on value

    I did not know, I changed them to CODE now.

    I tried to copy paste both Sub file_names() + Sub Macro1() (renamed into Background() and Macro10()).
    Background() calls Macro10().
    I thought it would work by changing the GetFolder(pth) so that it picks up the value (which is the path of the folder with different pictures) from a cell.
    It worked but it still displays the images from the big folder, it doesn't display the images of the path it is supposed to find in the cell.
    I really have no idea how to do it.
    Last edited by Soraka; 05-15-2023 at 09:10 AM.

+ 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. Duplicate, rename, and output image files to folder based on criteria in Excel Column
    By S Thibault in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-11-2023, 09:49 AM
  2. Random background image from folder with 1 error
    By Soraka in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-14-2023, 06:19 PM
  3. [SOLVED] Macro to change the background image and copy the image filename into a cell
    By Zenarte in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 03-27-2022, 02:51 PM
  4. copy image file from one folder to another based on a list
    By San75 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-23-2019, 06:15 AM
  5. Vlookup into an image folder and importing the image into the spreadsheet?
    By talan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-30-2017, 12:54 PM
  6. Macro to import image from folder based on Style Number
    By jussie in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-10-2015, 04:48 AM
  7. Replies: 1
    Last Post: 04-03-2012, 02:02 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