Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    May 2003
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Insert jpg files into Excel cells (Excel 2000)

    I am making a database of art in Excel, with title, artist, purchase date, etc. I want to insert a link to a jpg photograph of the art in another directory. I am using the hyperlink function, but it is unwieldy and time-consuming. Is there an easy way?

    Also, I want to save all the completed data to a CD-R, including the Excel file and the images. When I did a trial of this, the cell references were fixed and I couldn't open the jpg file from the Excel file in the E: drive.

    Tom R

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Insert jpg files into Excel cells (Excel 2000)

    Here is an alternative approach that uses the FollowHyperlink VBA function:

    You can put the path to the .jpg files in a cell, say Q1. Don't forget to change the value before saving to CD-R.
    Instead of creating hyperlinks, just enter the file names (without path) of the .jpg files in the appropriate column. For illustration purposes, I'll assume the file names are in F2:F100.
    Create a BeforeDoubleClick event handler for the worksheet (see below if you need instructions):

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    If Not Intersect(Target, Range("F2:F100")) Is Nothing Then
    ActiveWorkbook.FollowHyperlink Range("Q1") & "" & Target, , True, False
    Cancel = True ' Don't execute standard action of double click
    End If
    End Sub

    <img src=/w3timages/blueline.gif width=33% height=2>

    To create the event handler:
    <UL><LI>Start the Visual Basic Editor (Alt+F11)
    <LI>Activate the Project Explorer (Ctrl+R)
    <LI>Expand your workbook until you see the worksheet that contains the database.
    <LI>Double click the worksheet.
    <LI>Enter or copy the code as displayed above.
    <LI>Switch back to Excel.[/list]Replace the range addresses in the code by those appropriate for your worksheet.

  3. #3
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Insert jpg files into Excel cells (Excel 2000)

    Hi Tom

    I've done similar projects, and have found it easiest to use VBA code with a userform to display the graphics. This has the advantage of displaying a modal graphic on top of the spreadsheet, rather than in another application like IE, that has to be switched back & forth from. It also means that the .JPG viewer is right there, inside Excel, which might be significant if your CD catalog is being run on an unknown system. Further, the userform can be used to neatly frame the graphic, so that its display doesn't take up any more screen real estate than it needs. (Note that I deal only with "thumbnails", significantly smaller than the full screen size.)

    I've had good feedback from using a toolbar button to display (and close) a graphic corresponding to the active row, but any event can be used to display it, such as the double-click event mentioned by Hans. If you're interested in looking at this method, I can modify & post some sample code.

    Alan

  4. #4
    New Lounger
    Join Date
    May 2003
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Insert jpg files into Excel cells (Excel 2000)

    Alan,

    Thanks for your advice. I was able to get the suggestion of HansV to work, but your comments about seeing the image inside Excel triggered another thought.

    The database is being prepared for an appraisal of the art. The appraiser uses Mac (though his son has a PC). Therefore, I would like to keep the viewer inside Excel, since I believe he can open an Excel file and jpg files from a W2K formatted CD.

    I have attached a small spreadsheet with HansV's suggestion incorporated into it. Any advice you could provide will be deeply appreciated.

    Tom Reynolds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •