+ Reply to Thread
Results 1 to 7 of 7

Using excel to rename jpgs

  1. #1
    Registered User
    Join Date
    12-17-2009
    Location
    Kirkcaldy, Scotland
    MS-Off Ver
    Microsoft® Excel® for Microsoft 365 MSO (Version 2201) 64-bit
    Posts
    75

    Using excel to rename jpgs

    Hi I am not sure if this is a function that Excel can help with at all so hoping some genius can help out.

    I have one jpg image named SECONDARYIMAGE3 that I need to duplicate across hundreds of items to show the same "secondary information image" across a range of products.

    I have a list of the product codes on an excel spreadsheet in column A along with the required image name in column B - each code is unique (couple of examples below)
    CODE IMAGE CODE
    B03MVJDJY2 B03MVJDJY2.SECONDARY.jpg
    B02SUYDJY1 B02SUYDJY1.SECONDARY.jpg

    Is there any formula I can use to transfer the product code name from Column B and duplicate multiple times to the one image I have to show the new image code names?

    I am guessing there isnt an easy way to do this but if I cant find a way I am going to have to copy and paste each unique name into an image folder containing hundreds of duplicate copies of the same image.

    Any ideas/suggestions would be greatly appreciated.

  2. #2
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: Using excel to rename jpgs

    Although this is posted in the Formula section, it'd be quite easy to do with vba.


    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    12-17-2009
    Location
    Kirkcaldy, Scotland
    MS-Off Ver
    Microsoft® Excel® for Microsoft 365 MSO (Version 2201) 64-bit
    Posts
    75

    Re: Using excel to rename jpgs

    Thanks for that - must admit I've never used VBA so not sure how to do this? Is it easy to do? I've saved the sheet as an xlsm file but not sure how or wher eto add your formula? Sorry - Im guessing this is pretty basic stuff but as a complete novice to visual basic I am clueless lol

  4. #4
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Using excel to rename jpgs

    ALT + F11 will open up the VBA Editor.
    From the INSERT Dropdown, choose "Module"
    There will then be a large white text box on the right hand side.
    Paste the code in there.
    You can now close the VBA Editor (no need to save, it will save as part of your workbook)
    I believe the Macros icon is in the View Ribbon.
    Did that work?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  5. #5
    Registered User
    Join Date
    12-17-2009
    Location
    Kirkcaldy, Scotland
    MS-Off Ver
    Microsoft® Excel® for Microsoft 365 MSO (Version 2201) 64-bit
    Posts
    75

    Re: Using excel to rename jpgs

    No but I suspect it is more to do with me than what you have suggested - I'll do some more research on VBA to get a better understanding of it then try again. Thanks for your help.

  6. #6
    Registered User
    Join Date
    12-17-2009
    Location
    Kirkcaldy, Scotland
    MS-Off Ver
    Microsoft® Excel® for Microsoft 365 MSO (Version 2201) 64-bit
    Posts
    75

    Re: Using excel to rename jpgs

    I did change the path name to where I had the image and the spreadsheet on my I:drive rather than C drive (in a folder) so I changed the path name to Path = "I:\GHTest\2021 New Products\secondary images\" - was I right to do that (and do I need to add anything to the sourceimage? When I run the VBA it says file not found and highlights Attachment 717850


    Sub CreateCopy()
    Path = "I:\GHTest\2021 New Products\secondary images\"
    sourceimage = "SECONDARYIMAGE3.JPG"

    For r = 1 To 10 'or however many there are
    FileCopy Path & sourceimage, Path & Range("B" & r).Value
    Next
    End Sub

  7. #7
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: Using excel to rename jpgs

    so your codes, e.g. B03MVJDJY2.SECONDARY.jpg, which are the new file name are in column B

    Right-click the tab of the worksheet containing those codes and choose View Code from the popup menu.
    Put the code in the resulting window.

    Please Login or Register  to view this content.
    looks correct, but SECONDARYIMAGE3.JPG should also be in this folder.

    Please Login or Register  to view this content.
    Assuming your codes in column B start at row 1 to row 10, then Range("B" & r).Value should be the new file name contained in each cell, e.g. B03MVJDJY2.SECONDARY.jpg

    Click in the code and press F8 to step through it. While stepping through, if you hover the mouse over bits such as Range("B" & r).Value, the tooltip should show the name of the code in that cell.

+ 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. Excel charts as jpgs to specific powerpoint
    By sandra.pa in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-22-2018, 03:29 AM
  2. Conditional Formatting on .jpgs
    By HabsFan89 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-21-2016, 09:41 AM
  3. Hyperlink from excel table to jpgs and burn a DVD that works on its own
    By exfordy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-18-2013, 05:04 PM
  4. saving charts as jpgs from multiple sheets
    By dadevil in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-22-2010, 09:50 AM
  5. Batch generation of jpgs from charts in Mac Office 2008
    By rajab in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 06-30-2009, 01:52 AM
  6. Importing jpgs from excel to word data merge
    By comountain in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-07-2009, 03:37 AM
  7. [SOLVED] Add multiple excel worksheets(tabs) with jpgs
    By [email protected] in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-13-2005, 03:06 PM

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