Hyperlink to Photos When Moving Files

  • Re: Hyperlink to Photos When Moving Files


    Note that I corrected a few folder names - when it would give me a "Can't open the file" error I compared folder names to the code and made corrections

  • Re: Hyperlink to Photos When Moving Files


    :yikes:I am extremely annoyed at myself now... I must have renamed the function without renaming the part which gives it its output value... :yikes:
    Thanks for posting the code. It was something to do with that line.
    Change "TagNo" with "ImageName". Normally that should do the trick.

  • Re: Hyperlink to Photos When Moving Files


    You DA MAN........ works PERFECTLY. Still minimizes the photo, but that's a minor issue at this point.

    Still not sure how I'll handle the multiple photos per item issue, but may just let it fly as is and see if they pitch a fit........ Some photos, by the way, are for multiple items - I'll see how that works too.

    You CANNOT know how much I appreciate all the work!! You've saved me a ton of time and headaches in trying to either embed the photos or hyperlink (and having to fix those everytime I move the files)......

  • Re: Hyperlink to Photos When Moving Files


    Glad I could help! Sorry for my sloppyness at some points...
    Could you post your final code as a solution for people looking for help on similar issues?
    You can wrap your code using: (code) code in here (/code) (use square brackets instead of normal ones)

  • Re: Hyperlink to Photos When Moving Files


    Ok, I see issues, but they deal with my file names...... In cases where there are multiple photos for 1 item, the photos are named - for example - "BS-114 (1).jpg" and "BS-114 (2).jpg". These won't open... I had originally thought that wouldn't be an issue, but just now realized (DUH) that we've asked it to look for the tag number as the file name - and anything other than what's found in columns A-C is ignored.

    We also have photos which represent more than 1 item - these are named - for example - "BS-001, 002, 003 and 004.jpg". Code won't pick those up either.

    Any way to insert wildcards in the code looking for the file name?

  • Re: Hyperlink to Photos When Moving Files


    Sloppiness?????????? Oh HELL no. You took your personal time to help ME, and worked it until we (YOU) got it right.... It's a complicated issue, so you had to do a lot of brainstorming - on your weekend, no less - and I am more appreciative than I could ever express.

  • Re: Hyperlink to Photos When Moving Files


    You could add a column in your data with a backup name for the picture. By only putting the names for exceptions in there you could use the following code:
    (given that you have added the column after C, so a new column D):

  • Re: Hyperlink to Photos When Moving Files


    That would require multiple columns then? For example, I'd have one column with the (1), one with the (2), and if there's a 3rd picture another with the (3).

    But that would also require multiple other columns for the photos which pertain to multiple items - but the additional numbers in the file name aren't always the same........ For example, a photo might be named "BS-001, 002, 003 and 004.jpg" or "BS-010, 011, 012, 013 and 014.jpg"

  • Re: Hyperlink to Photos When Moving Files


    Will it work with hidden columns? I can add them all, but wouldn't want them showing.....

  • Re: Hyperlink to Photos When Moving Files


    VBA code always works with hidden columns. I didn't think of the multiple image ones yet....
    If an image name applies to several items, put it into the column D. If an item has several images fill in the column D with multix (x being the number of images).

  • Re: Hyperlink to Photos When Moving Files


    Ok, so for photos that apply to several items, Column D would read - example - ",002,003 and 004"?

    For the items with several photos would x be the number of photos - example, 3 - or the numbers of the photos - example, (1) (2) (3)

  • Re: Hyperlink to Photos When Moving Files




    With this code:
    If you have one image which is valid for several items put the entire image name (just without .jpg) into column D
    If you have several images write "multi4" into column D (without " and 4 being the number of images you have for that item)
    It will open all four images.

    Regards

    Attila

  • Re: Hyperlink to Photos When Moving Files


    Once change to the code - changed the column from "N" to "O" at the top (after adding column D). Everything works fine - single pics - but the multiple pics for 1 item doesn't...........

  • Re: Hyperlink to Photos When Moving Files


    Putting the file name for images which apply to multiple items DOES work.

    Wish I could figure out why it minimizes the photo - bugs me - but given the the progress so far I can live with it!

  • Re: Hyperlink to Photos When Moving Files


    Glad it works :) I'll have a think about the minimize issue.
    Are you sure that it is not due to some preferences you have set? When I tested the line of code to open an image it was opened fullscreen...

  • Re: Hyperlink to Photos When Moving Files


    and here's a stupid question I should have thought of before....... Will clients - or anyone who wants to view the picks from the report - need to have VBA installed? I would assume so....

  • Re: Hyperlink to Photos When Moving Files


    I was just looking for "options" or "preferences" for Windows Picture Viewer - but there doesn't seem to be any, at least not that I can find. I'm looking around now to see if something I have set - nothing that I KNOW of - is causing that.

    Thoughts on the "multiple images"? Can't get that to work just yet.....

  • Re: Hyperlink to Photos When Moving Files


    Check the name of the images linked to that item, and see if it fulfills these criteria:
    [TagNo][space][open bracket][image number][close bracket][.jpg]

    If you could give me the exact syntax of your multiple images, maybe I could fix the code.

    And no, those who have excel will have vba. No problems with that at all.

  • Re: Hyperlink to Photos When Moving Files


    Multiple images are named by numbers in parentheses - example - "BS-001 (1). jpg", "BS-001 (2).jpg" etc. Most of the ones that have multiple images will only have 2, though a few have 3

  • Re: Hyperlink to Photos When Moving Files


    Try using this sub instead of the one you already have:

    Code
    Sub ShowImage(Folder As String, Target As Range)
    Dim i As Integer
    If InStr(Range("D" & Target.Row), "multi") > 0 Then GoTo MultipleImages
        Shell ("c:\windows\system32\rundll32.exe C:\WINDOWS\system32\shimgvw.dll,ImageView_Fullscreen " & ThisWorkbook.Path & "\Photos\" & Folder & "\" & ImageName(Target))
    Exit Sub
    MultipleImages:
        For i = 1 To Replace(Range("D" & Target.Row).Value, "multi", "")
            Shell ("c:\windows\system32\rundll32.exe C:\WINDOWS\system32\shimgvw.dll,ImageView_Fullscreen " & ThisWorkbook.Path & "\Photos\" & Folder & "\" & ImageName(Target, i))
        Next i
    End Sub

    All I did was replace vbNullString with "", it should be identical, and vbnullstring is considered better coding practice, but who knows... Tell me if it made a difference.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!