Results 1 to 10 of 11

Thread: Insert Picture in a Cell UDF

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    1
    Rep Power
    0
    Quote Originally Posted by Admin View Post
    Hi All,

    Here is a UDF, which helps to insert a picture into a cell.

    Enjoy !!

    Code:
    Function INSERTPICTURE(ByVal PictureFullName As String, Optional ByVal PicWidth As Single = 200, _
                                                            Optional ByVal PicHeight As Single = 150)
            
        '// Author      : Kris @ ExcelFox.com
            
        Dim CellActive      As Range
        Dim picPicture      As Object
        
        Set CellActive = Application.Caller
        
        For Each picPicture In CellActive.Parent.Pictures
            If picPicture.TopLeftCell.Address = CellActive.Address Then
                picPicture.Delete
                Exit For
            End If
        Next
        
        Set picPicture = CellActive.Parent.Pictures.Insert(PictureFullName)
        With picPicture
            .Left = CellActive.Left + 1
            .Top = CellActive.Top + 1
            .Width = PicWidth
            .Height = PicHeight
        End With
        
    End Function
    use like =INSERTPICTURE("C:\Pictures\MyPicture.jpg")

    PFA sample workbook.
    The codes seem insert a picture once only. I can't do second time by putting a new path.

  2. #2
    Senior Member
    Join Date
    Apr 2011
    Posts
    190
    Rep Power
    15
    Kris

    I have used your code -- it works great -- I am using the one where I place pictures on a chart. However I have a sheet that contain all my settings --- so I have copied my picture into that sheet -- I am now trying to copy that picture (I have identified it as a shape) ---- I can copy shapes from one sheet to another --- But I cannot figure out how to copy a shape fom a sheet to a chart --- any idea
    Thanks
    Rasm
    xl2007 - Windows 7
    xl hates the 255 number

  3. #3
    Junior Member
    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0
    HI2 AND THANKS FOR SHARING NICE INFO

Similar Threads

  1. Question on UDF LookUpConcat
    By K2` in forum Excel Help
    Replies: 4
    Last Post: 05-07-2013, 10:25 PM
  2. Trouble implementing UDF's
    By ProspectiveCounselor in forum Excel Help
    Replies: 4
    Last Post: 05-06-2013, 08:07 PM
  3. Automatically Insert Row
    By marreco in forum Excel Help
    Replies: 7
    Last Post: 12-21-2012, 06:43 PM
  4. Replies: 4
    Last Post: 05-03-2012, 10:28 AM
  5. UDF to Create In-Cell Chart in Excel
    By Admin in forum Download Center
    Replies: 0
    Last Post: 08-13-2011, 09:53 AM

Tags for this Thread

Posting Permissions

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