+ Reply to Thread
Results 1 to 6 of 6

dynamic picture embedding

Hybrid View

  1. #1
    Registered User
    Join Date
    06-17-2008
    Posts
    3

    dynamic picture embedding

    I have a directory with tens of thousands of images that each have unique eight digit numbers.
    I have a spreadsheet that does a lot of miscellaneous things. I am trying make a way to type the eight digit picture number into one cell, and have the picture show up on the same sheet.
    Are there any possibilities for this type of dynamic embedding?

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello addysdddy,

    Welcome to the Forum!

    Seems to be the day for picture questions. A macro can be written to dynamically load the picture on the worksheet. It would help to see your workbook so I can be more specific in answering your question. The maximum upload file size is 100kb. Pictures can use this space very quickly and zipping doesn't always reduce pictures significantly. So, you may want to send the workbook and a separate file with the pictures.

    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    06-17-2008
    Posts
    3
    Hi, thanks for your reply. I've attached a sample of the spreadsheet and a few pictures (courtesy xkcd).
    I'm typing the picture number in cell F12. In cell F13 I put a sloppy formula that creates a link to click to load the picture off a local server.
    Instead of the link in F13, I want the picture to show.
    My apologies if you smell any remnants of my vb code. It was really quite awful and I tried to purge it.
    Attached Images Attached Images
    Attached Files Attached Files

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello addysdddy,

    The following macro has been added to the attached workbook. It will load the picture file, if it exists, and display it below Cell "E13" in a Image control. This control will automatically size itself to the pictures dimensions. Currently, all the files searched for are ".jpg" extension. The macro automatically runs when the value in cell "F12" changes. Set the DirPath to where your picture files are located.
    Sub ShowPicture()
    
      Dim DirPath As String
      Dim FileName As String
      Dim Pic As StdPicture
        
        DirPath = "C:\Documents and Settings\My Documents\My Pictures"
        FileName = Worksheets("Sheet1").Range("F12")
        FileName = DirPath & "\" & FileName & ".jpg"
        
        If Dir(FileName) <> "" Then
          Set Pic = LoadPicture(FileName)
            With Worksheets("Sheet1").Image1
              .Picture = Pic
              .Height = Pic.Height / 25.4
              .Width = Pic.Width / 25.4
            End With
        Else
          MsgBox "The Picture File was not found -" & vbCrLf & FileName, vbExclamation
        End If
        
    End Sub
    Sincerely,
    Leith Ross
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    06-17-2008
    Posts
    3
    Great! Thanks for your help

  6. #6
    Registered User
    Join Date
    06-12-2012
    Location
    Grant
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: dynamic picture embedding

    I am using Excel 2010 and trying to import multiple pictures into an excel workheet named photo1. I am obtaining the path name and file name from the same workbook from worksheet named photo log. I am having issues with the code line:

    With Worksheets("Photo Log").Image1

    The entire code is:

    Sub ShowPicture()

    Dim DirPath As String
    Dim FileName As String
    Dim Pic As StdPicture

    DirPath = "S:\Customer Files\RCC Consultants\1102 - Dimondale\311324 - 4262 - Site Inspection\2.5 Project Managment - Daily Job Reports\DIMONDALE"
    FileName = Worksheets("Photo Log").Range("f30")
    FileName = DirPath & "\" & FileName & ".jpg"

    If Dir(FileName) <> "" Then
    Set Pic = LoadPicture(FileName)
    With Worksheets("Photo Log").Image1
    .Picture = Pic
    .Height = Pic.Height / 25.4
    .Width = Pic.Width / 25.4
    End With
    Else
    MsgBox "The Picture File was not found -" & vbCrLf & FileName, vbExclamation
    End If

    End Sub

    I get a Run Time error ' 438'
    Object doesn't support this property or method.

    Help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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