MacLochlainns Weblog

Michael McLaughlin's Technical Blog

Site Admin

Add Image to a Comment

with 139 comments

How you add an image to a comment isn’t exactly what I’d call easy but it is straightforward. One of my students noted that a tip in Microsoft Office Excel 2007 Bible (a truly good book on Excel 2007) didn’t provide the magic to insert an image into a cell comment. Updated this post and provided a new blog post that lets you add an image on Excel 2007, Excel 2010, and Excel 2011 with a VBA User-Defined Function (UDF). UDFs differ from VBA macros and you can find my Excel UDF Tutorial here.

I’d have to say that it did but it didn’t. Basically, the general idea is there but a step of magic requires you to know something else. You need to place your cursor on the highlighted edge of an editable comment before right clicking to launch the context menu. If your cursor is on the text portion of the comment, the context menu operates differently. The Format Comment … menu choice launches a different set of options dependent on your location in an editable comment.

I’ve modified the tip by adding the sentence in blue, with what I think it should say. “You can also display an image inside of a comment. Just make sure you right click on the edge not inside the text box of the comment. Select the Colors and Lines tab in the Format Comment dialog box. Click the Color drop-down list and select Fill Effects. In the Fill Effects dialog box, click the Picture tab and then click the Select Picture Button to specify a graphics file.” – Microsoft Office Excel 2007 Bible, Page 91.

Hoping to help my students and others learn the magic, here are some steps. It’s a shame the best way to do this screen capture is on Apple OS X, but that’s life!

1. Right click on the cell to launch the shortcut menu, like this:

insertcomment1

2. Click on the Insert Comment menu item, which launches the comment with the name of the user. If you only want an image, highlight the user name with the mouse and delete it. The backspace key doesn’t work all the time and I’m not sure why that’s the case on Excel 2007. The backspace key always works on Excel 2008 for cell comments.

insertcomment2

3. The tricky part (maybe if you’re new to Microsoft Office) requires you to place the mouse on the edge of the comment box, over the bar-dot line, and right click the mouse to launch the shortcut menu in Excel 2007. The Mac version requires you to double click the cell to get the active sizing border, and another double click to launch the appropriate shortcut menu. Click the Format Comment … menu item in either Excel 2007 or 2008.

insertcomment3

4. Click on the Colors and Lines tab to see the following dialog.

insertcomment4

5. Click on the simple drop-down for the Color option in Excel 2007. Click on the spinner for the Color option in Excel 2008. Inside the box, click on the Fill Effects … menu item. It launches the broadest scope version of the Fill Effects dialog.

Windows Excel 2007 dialog:

insertcomment5

Mac Excel 2008 dialog:

insertmaccomment5

6. Click the Picture tab. Inside the Picture tab, click the Select Picture … button to find a picture on your disk drive.

insertcomment6

7. Click the Lock picture aspect ratio check box if you’re inserting a small landscape orientation image in Excel 2007. There’s no such option in Excel 2008 (newer product, less features, hmm …). Unfortunately, portrait photos don’t seem to preserve aspect ratios as well in Excel 2007.

insertcomment7

8. Now when you click on the cell, the image is visible. If you need to resize an image, right click on the cell to launch the shortcut menu and click the Edit Comment menu item. You can then resize the display of the image.

insertcomment8

Hope this helps some folks.

Written by maclochlainn

January 29th, 2009 at 12:59 pm

Posted in Uncategorized

139 Responses to 'Add Image to a Comment'

Subscribe to comments with RSS or TrackBack to 'Add Image to a Comment'.

  1. Nice cow jumping over the moon!

    Kendon

    30 Jan 09 at 11:18 am

  2. I love the picture!!

    Michael Reed

    30 Jan 09 at 11:18 am

  3. Thanks needed to fill in a colour for my comment box followed your directions & worked great!

    Darlene

    11 Feb 09 at 4:37 am

  4. Hi !!!! :)
    I am Piter Kokoniz. Just want to tell, that your blog is really cool.
    I want to ask you: what was the reason you started this blog?
    Sorry for my bad English. :)
    Tnx!
    Your Piter

    PiterKokoniz

    7 Apr 09 at 4:27 pm

  5. More or less because I thought posting information could help people.

    maclochlainn

    7 Apr 09 at 7:48 pm

  6. Thank you, Michael!
    It was easy and useful:)

    Tanya

    19 Apr 09 at 10:44 am

  7. Thank you very much for posting this info, it was so very useful….

    Valerie

    21 Apr 09 at 12:10 am

  8. That’s nice tips. Is it possible to show query result on the cell comment ? How ?

    Thanks a lot

    alex

    5 May 09 at 9:02 am

  9. @ Alex

    Yes, it’s possible. Just select the comment (the outer rim, not the inside of the cell) and go directly into the formula tap and type for example:

    =A1

    It is not possible to calculate or add upp formulas in the comment box such as

    =A1&A2

    Valur

    15 May 09 at 3:42 am

  10. Hi,

    It doesn’t show any other tab except Font in Excel 2007.

    Inderpreet

    Inderpreet

    10 Jun 09 at 6:57 am

  11. This is from step #3, which is where I think you’re getting stuck. “The tricky part (maybe if you’re new to Microsoft Office) requires you to place the mouse on the edge of the comment box, over the bar-dot line, and right click the mouse to launch the shortcut menu in Excel 2007.” A different context dialog launches if you’re not very percise with the postion of your cursor. If that doesn’t help, could you describe exactly where you’re stuck and the steps taken?

    maclochlainn

    10 Jun 09 at 12:38 pm

  12. Thanks a lot … I tried excel help but no use. Really you saved my time.

    Sree

    16 Jun 09 at 4:39 am

  13. Hi,

    I want to use this option but my excel 2007 doesn’t show any other tab except Font in Excel 2007.

    help! :)

    Amir

    Amir

    29 Jul 09 at 2:28 am

  14. Just make sure you right click on the edge not inside the text box of the comment.

    maclochlainn

    29 Jul 09 at 10:15 pm

  15. Great answer – thanks.

    Roland

    17 Nov 09 at 3:57 am

  16. You are THE MAN!!! That is some tricky part about the edge!!!! Congrats about the site is VERY useful!!!

    Erik

    20 Dec 09 at 3:25 am

  17. THANK YOU!!!!

    Rhiana

    27 Jan 10 at 12:35 pm

  18. can i call this picture to another cell
    for example if i enter a data in “A1″ cell i can call that in another cell by using equal to (=) function. in the same way can i call the comment picture to another cell

    king

    11 May 10 at 3:32 am

  19. I would like to copy the image that is in a comment box someone has sent me, is there a way to do that?

    Diane

    12 May 10 at 10:50 am

  20. Hi,

    I am using Excel 2007, however when I try and format the comment I only get very limited options (I only have a font tab, no colours or lines tab; and I also do not have the options for gradient et cetera.) Am I running a cheaper/limited version of excel or is ther esomething I can do to unlock these options?

    Jamie W

    13 May 10 at 11:16 pm

  21. please excuse my previous comment I neglected to read more carefully through your replies, thank you all osrted. Great help!!

    Jamie W

    13 May 10 at 11:17 pm

  22. How do assign picture in the cell?

    ali

    24 Jul 10 at 3:14 am

  23. You need to click on the right side of the cell as stated in the post.

    maclochlainn

    24 Jul 10 at 7:43 am

  24. Very Good !!

    Veronesi

    21 Aug 10 at 1:37 pm

  25. I didn’t know that you can do this!
    Clearly explained with screen shots.

    Thank you. I learned something today.

  26. Thank you very much. This helped tremendously…

    Santana2710

    2 Sep 10 at 10:44 am

  27. yes, but what if I want the picture to be inside the cell

    santaino

    19 Sep 10 at 4:24 am

  28. I’m with Santaino: Want to embed image in cell, not in comment, so that cell text + image will appear in different cell referencing the one with image (e.g. cell A1 contains “text & image”; cell A2 contains “=A1″ and displays A1’s text & image).

    guidonero

    7 Oct 10 at 11:52 am

  29. You can’t assign an image to a cell property. It’s simply not supported by the product.

    maclochlainn

    21 Oct 10 at 10:35 pm

  30. Thanks mastaru

    mallikarjunarao

    28 Oct 10 at 6:49 am

  31. Thank you very much! really great !!!

    Ilya

    3 Nov 10 at 6:40 am

  32. Hey this post is nice! Thanks!

    Excellio

    12 Dec 10 at 6:44 am

  33. thanks for the post, its have given new dimensions to work.

    varun

    16 Jan 11 at 4:03 am

  34. Easily done with Excel Image Assistant.

    Peter

    5 Feb 11 at 3:53 pm

  35. Yes, individuals can purchase an Add-on (that I’ve not tested nor do I endorse) for $19.95 or they can click a couple buttons and save the money. Also, everybody should know that Peter’s software only works on native Windows not on Mac OS X. ;-)

    maclochlainn

    5 Feb 11 at 10:07 pm

  36. I’m using free demo version which did job in 3 clicks (after proper setup settings). There is no need for further action, like lock aspect ratio, re-size image etc … by the way, nice blog.
    Regards,
    Peter

    Peter

    6 Feb 11 at 6:15 am

  37. Great Tutorial. Thank you!!!

    zavragiu

    9 Feb 11 at 5:55 am

  38. Thanks :)

    Tom

    14 Feb 11 at 9:29 am

  39. This is great. I checked one tip on the net and the explanation given was for excel 2003. I couldn’t get it done. I checked this blog and you have explained it.

    Thank again.

    Joe

    6 Mar 11 at 11:52 pm

  40. >You can’t assign an image to a cell property.

    Thanks a heap for that bit of info, MacLochlainn. Knowing that something “can’t” be done with a product eliminates a lot of futile searching for an answer that just isn’t there.

    guidonero

    7 Mar 11 at 7:50 pm

  41. Ci sono stati tante anni da quando scrivere molto in Italiano. Mi farebbe piacere leggere un suo commento, pero è possibile come uno proprietà di commento. Fortunatamente, è possibile modificarlo dopo aver risposto in uno commento. Ce l’ho scritto così.

    For everybody else that doesn’t read Italian, it isn’t possible as a property of a cell but is possible as a property of a comment.This simple macro replaces all the manual steps but I know some folks are so adverse to using VBA. They won’t use it. For those who prefer to use VBA, now you have an option.

    ' Add a presized photo as a comment to an Excel cell, done on Excel 2011 for the cell reference.
    Sub InsertComment()
      Dim commentBox As comment
      ' Any existing comments must be cleared before adding a new one.
      Range("A1").ClearComments
      Set commentBox = Range("A1").AddComment
      With commentBox
        .Text Text:=""
        With .Shape
          .Fill.UserPicture ("Macintosh HD:Users:mclaughlinm:Desktop:WizardChess.png")
          .ScaleHeight 3#, msoFalse, msoScaleFormTopLeft
          .ScaleWidth 2.4, msoFalse, msoScaleFromTopLeft
        End With
        .Visible = False
      End With
    End Sub

    Somebody asked me to replace the limiting value and make it dynamic as a subroutine. What’s different below is that the text string in the current cell becomes the file name of a file in my Mac OS X Desktop, provided it’s file type is .png. There are many other possibilities but this struck me as the most likely thing somebody may want to do. As noted by a comment below, my assumption was that all file names would be strings in the cell. When the value in the cell is a number, you need to explicitly cast it as a string with the Cstr() function (added below).

    ' Add a presized photo as a comment to an Excel cell, done on Excel 2011 for the cell reference.
    Sub InsertComment()
      Dim commentBox As Comment
      ' Any existing comments must be cleared before adding a new one.
      ActiveCell.ClearComments
      Set commentBox = ActiveCell.AddComment
      With commentBox
        .Text Text:=""
        With .Shape
          .Fill.UserPicture ("Macintosh HD:Users:mclaughlinm:Desktop:" + Cstr(ActiveCell.Value) + ".png")
          .ScaleHeight 3#, msoFalse, msoScaleFormTopLeft
          .ScaleWidth 2.4, msoFalse, msoScaleFromTopLeft
        End With
        .Visible = False
      End With
    End Sub

    You can remove the A1 range comment with the following macro:

    'Remove an image from a cell comment.
    Sub RemoveComment()
      Range("A1").ClearComments
    End Sub

    You can remove the dynamic range comment with the following macro:

    'Remove an image from a cell comment.
    Sub RemoveComment()
      ActiveCell.ClearComments
    End Sub

    This is what would appear on Excel 2011 on the Mac OS X if the file name was Wizard's Chess:

    Wizard's Chess Image

    I finally just wrote the whole thing in a new post. At least how to make it work as image comments.

    maclochlainn

    7 Mar 11 at 9:55 pm

  42. [...] how you can automate embedding images in cell comments [...]

  43. Thank you very much! really great .
    Clearly explained with screen shots.

    Min Thein

    12 Apr 11 at 5:45 pm

  44. Why on my excel 2007 don’t let me format the coments, only the Font?

    HSantana

    27 Apr 11 at 3:27 pm

  45. Thank you very much! I’m no “Excel-Crack”:-), so I googled my question and found your great article. This picture issue was exactly what I needed.
    Keep it up.
    Bye
    Thomas

    Thomas

    29 Apr 11 at 3:28 am

  46. I tried the demo version of the Excel Image Assistant… it is just floating the image, not embedding it. I find this such an annoying limitation of the software, as all of my spreadsheets include logos (adding them into the comments box is not really an option).

    Laura

    11 May 11 at 6:34 pm

  47. Certainly, it is less than ideal. ;)

    maclochlainn

    11 May 11 at 6:58 pm

  48. thanks for this stuff…

    karthik

    2 Jun 11 at 12:46 am

  49. THANK`S FOR YOUR GUIDANCE

    ALIREZA

    8 Jun 11 at 6:10 am

  50. I don’t usually comment when I find what I’m looking for online, but your information was so dead on accurate to answer all of my questions that I just wanted to personally say thank you.

    MaccG

    8 Jun 11 at 8:28 am

  51. I have Excel 2003 and am wondering if I can do a format for the comments as a whole? I know how to do them individually but cannot find a way to set up a format that carries into every comment I create.

    Excel help says it is in the Format drop-down menu but my version does not have a “comment” option in that drop-down.

    I am really just wanting to set a standard font so I don’t have to change it every time.

    Thanks.

    Fred

    20 Jun 11 at 7:47 am

  52. When I select Format Comment I only get the font tab, none of the others (i.e. no “Colors & Lines” tab). Any ideas why??

    Kelly

    27 Jun 11 at 6:40 am

  53. Step #3, you need to right click while hovering on the edge.

    maclochlainn

    28 Jun 11 at 7:05 pm

  54. Is it possible to extract the original image from a comment box once it’s been inserted? I have an Excel file with an image in a comment (generated by someone else, apparently using this method), and I need to check the image’s EXIF data to see if the image has any geo-location data.

    Buckethead

    20 Jul 11 at 12:19 pm

  55. Just what I was looking for! Maybe one day MSFT will change it so that we can paste the image into excel comments vs. saving to disk first. I will take it, much better than pasting a huge image or trying to use Word like Excel. THANKS!

    TJ

    21 Jul 11 at 8:22 pm

  56. Rony

    23 Jul 11 at 2:46 pm

  57. Great help.

    Thyagu

    28 Jul 11 at 5:13 am

  58. THANKS ! ! !

    Bobbie

    2 Sep 11 at 2:23 pm

  59. I love this! Very cool indeed.

  60. Thanks a lot.. This was what I was looking for..

    Samjosh

    2 Oct 11 at 6:49 am

  61. love it <3
    thank you so much, this is very cool

    Theresia

    24 Oct 11 at 12:56 am

  62. Need your help! I have problem when the name of picture is number. For example product code 1234.png. For some reason in this case the line:

    .Fill.UserPicture ("Macintosh HD:Users:mclaughlinm:Desktop:" + ActiveCell.Value + ".png")

    It doesn’t work. When I change the image name to letters, it’s working perfect.

    Norbert

    30 Oct 11 at 1:05 pm

  63. Enclose the ActiveCell.Value in a Cstr() function call, like this:

    Cstr(ActiveCell.Value)

    The number can’t be implicitly cast to a string because Visual Basic sees it as a loss of precision. The Cstr() function call explicitly casts it.

    maclochlainn

    30 Oct 11 at 4:03 pm

  64. MAN THIS WAS SO HELPFUL THANK YOU

    soham

    5 Dec 11 at 2:10 pm

  65. I didn’t read anything on how to add a screen shot to a comment.

    Bentley

    13 Dec 11 at 10:12 am

  66. A screen shot is simply a graphic image file. The best way to save those is to download SnagIt from TechSmith, save it as a file and then attach it. If you’re looking for something specific, let me know what you’re looking for … if I can help or direct you, I will.

    maclochlainn

    13 Dec 11 at 2:23 pm

  67. THIS IS HELPFULL TO US BUT OUR SYSTEM NOT INCLUDE OVER ALL THE OPTIONS.

    PREMIKA

    21 Dec 11 at 9:44 pm

  68. i really appreciate you…this is really helpful

    prince

    22 Dec 11 at 9:45 am

  69. Huge help! thank you.

    marta

    28 Dec 11 at 11:57 am

  70. This is super fantastic!! Exactly what I wanted to do and very easy to understand. Step by Step photos help a lot.

    Thank you.

    Mary

    1 Jan 12 at 3:15 pm

  71. Hi Michael, I know this is really not exactly what your blog is about (comments) but I’m asking anyhow since you seems to be clever with this.
    I’m building a Home Inventory spreadsheet for insurrance purpose and I need to embed pictures in a cell, so the picture follow the sorting of the spreadsheet. Would also be great if it automatic resize to the size of the cell. I can do it with Apple Numbers but need xls.

    Peer

    7 Jan 12 at 4:27 am

  72. Is there any possible way to PRINT the image after it is attached to the cell? I am trying to help my son prepare for a test that includes both classification and visual recognition. I would like to print out “sorted” lists that include the image. Is this possible?

    Thank you SO MUCH for the clear instructions. I do not usually use Excel, and I was able to accomplish adding images on the first try with your wonderful directions!

    Melissa

    7 Jan 12 at 6:57 am

  73. Peer, I’m not aware of way to do it, but it might be possible in VBA.

    maclochlainn

    7 Jan 12 at 8:54 am

  74. Melissa, I don’t have a Windows environment handy today because I work principally on Mac OS X and Linux/Unix. However, I believe you can do it by using the VBA provided as a comment to an earlier question. Try setting the visible property to true, like:

      .Visible = True

    Let me know if it works.

    maclochlainn

    7 Jan 12 at 9:04 am

  75. Hi Michael,
    This is great, it allows data to be shared in a much less overwhelming way. I do have one question though. Is there any way to insert a chart rather than an image? I am hoping for a dynamic option that would save me the effort of having to save each chart as an image. I tried recording a macro and manipulating the code but don’t understand VBA quite well enough to make it work.
    I started with this…
    .Fill.UserPicture _
    “\\TTR\…..Composition.png”
    Can I replace “.Fill” or “.UserPicture” with a chart object?
    Thanks so much!

    Josh

    10 Jan 12 at 6:24 pm

  76. Josh,

    Just a guess, that I haven’t tested …

    ' Add a presized photo as a comment to an Excel cell, done on Excel 2011 for the cell reference.
    Sub InsertComment(chartName As Variant)
      Dim commentBox As Comment
      ' Any existing comments must be cleared before adding a new one.
      ActiveCell.ClearComments
      Set commentBox = ActiveCell.AddComment
      With commentBox
        .Text Text:=""
        With .Shape
          .Fill.Charts(chartName).CopyPicture xlScreen, xlBitmap
          .ScaleHeight 3#, msoFalse, msoScaleFormTopLeft
          .ScaleWidth 2.4, msoFalse, msoScaleFromTopLeft
        End With
        .Visible = False
      End With
    End Sub

    Let me know if it works?

    maclochlainn

    10 Jan 12 at 10:23 pm

  77. So, I really like this solution for a project that I’m working on, but I’m curious about how this works with the files. Do the image files become part of the excel files from there on, or do the image files need to be ported around with the .xlsx file when transferred between different computers that don’t share the image files? And, if they are embedded into the excel file, are there known issues when I start to embed 80-100 (smallish) picture files?

    Steven

    12 Jan 12 at 12:57 pm

  78. I love this image in the comment. Thanks very much!!

    Sue Ann

    12 Jan 12 at 1:06 pm

  79. Hi Michael,
    Is the code you posted supposed to go in a module? I’ve simply pasted your code in (without any alterations). Sorry, I’m just a newbee to VBA, but I can often find a way to make code work for me with the help of the debugger. But I am stuck, When I try running it, I get an empty macro selection box. It appears to me (with my limited know-how) that it is not recognizing this first line of code as a macro.

    Sub InsertComment(chartName As Variant)

    Am I doing something wrong
    Thanks for your help!

    Josh

    12 Jan 12 at 1:36 pm

  80. Josh,

    You write another VBA module that calls the other stored function, like this:

    Sub Test()
      InsertComment ("Chart1")
    End Sub

    Anyway, the following line doesn’t work because Charts can’t be a module for Fill:

     .Fill.Charts(chartName).CopyPicture xlScreen, xlBitmap

    I’d have to play with this but more or less you want a way to capture the name of the chart and associate it to a cell’s comment. I won’t have time to work on this for a bit but thought that I let you know where and how to test.

    maclochlainn

    13 Jan 12 at 1:13 am

  81. I am clicking on the place you are saying and all I get is the Font only tab. Even if I open up “Edit Comment” and click the “Format Comment.” I still only get the “Font” tab.

    Kyle

    7 Feb 12 at 11:57 pm

  82. Never mind I got it! Click on the mesh looking part of the comment. NOT the cell corner.

    Kyle

    7 Feb 12 at 11:59 pm

  83. Thanks & great help on imagination!

    Yet have you ever found a solution to put an image inside a cell?

    If so, let me know?

    nafeel

    3 Mar 12 at 10:44 pm

  84. No way to put it in the cell from what I’ve been able to discover. The cell doesn’t support the properties.

    maclochlainn

    3 Mar 12 at 11:31 pm

  85. What a great explanation for this “feature.” I’ve been using these steps for a while. But, when I add a row to the middle of the spreadsheet, most of the hover images in rows below are then distorted. I’ve gone back and tried it will the “lock aspect ratio” on the colors/lines tab checked/unchecked; also tried it with the lock aspect box on the size tab. Have you perhaps found the sweet spot selections to really lock these down?

    Thank you for the very helpful instructions!

    Debra

    5 Mar 12 at 1:30 pm

  86. Thanks for the info. I tried it and it worked. My problem is that I have .pdf files I would like to insert into the Comment. Is this possible or only pictures?

    Also, if I upload my document to a sharepoint file, will they still show there?

    Thank you again.,

    Ana

    13 Mar 12 at 10:46 am

  87. [...] How to add an image to a cell comment [...]

  88. Good help

    Paresh

    16 Mar 12 at 7:52 am

  89. Can you add a picture into an excel Cell so it is part of a database? I know you can insert a picture over a bunch of cells, but can you actually store in as a standalone cell or is the only way as a comment?

    Paula

    21 Mar 12 at 3:51 pm

  90. Thank you, thankyou, thankyou! I was tearing my hair since I could get only the Font options when I wanted to format a comment to insert a picture. You taught me to click on the outside of the box and not inside as I was doing. I had looked at a lot of advice on this issue but no one explained it as clearly as you did. Thanks again

    Rekha

    30 Mar 12 at 9:23 am

  91. LOVELY –
    Thank you so much for this great and helpful tutorial!

    Edge-clicking rocks
    Instead of clicking IN the box

    :)

    Vero

    13 Apr 12 at 7:20 am

  92. Thank you so much for this post, it’s extremely useful for organizing my dissertation research. I was wondering if you know if there is any way to preserve the aspect ratio of the image in Excel 2004 (step 7). I’m working with Excel 2004 for Mac Version 11.6.1 No option box pops up, so it very way well may be impossible (as is apparently the case for Excel 2008) but I wondered if you might know of any other way to preserve the aspect ratio manually.

    Thanks again!

    Abra

    20 Apr 12 at 5:25 pm

  93. so great
    guys thanks so much.
    i have just been seen as the hero of the day
    thanks again

    juliuss

    23 May 12 at 12:15 am

  94. Your information is very helpful. Thank You!

    Diane

    13 Jun 12 at 6:08 am

  95. Thanks a lot for posting this. It’s a cool feature, and I appreciate you taking the time to explain it so clearly.

    Paul

    24 Jun 12 at 11:55 pm

  96. For those who want to automate this process with Visual Studio Tools for Office (VSTO), here is a function that will do the insertion and sizing for you:

      Private Sub insertPicture(row As Integer, column As Integer, filename As String)
        Dim comment = CType(Cells(row, column), Excel.Range).AddComment(" ")
        '      adding a space prevents Excel from generating a bolded line with the username at the start of the comment.
    
        ' set comment size based on image size, up to a max value.
        Dim MAX_IMAGE_SIZE = 300
        Dim imageDimensions = System.Drawing.Image.FromFile(filename).Size()
        Dim scalingFactor = Math.Min(1, MAX_IMAGE_SIZE / Math.Max(imageDimensions.Height, imageDimensions.Width))
     
        comment.Shape.Fill.UserPicture(filename)
        comment.Shape.Height = Convert.ToSingle(imageDimensions.Height * scalingFactor)
        comment.Shape.width = Convert.ToSingle(imageDimensions.Width * scalingFactor)
        comment.Shape.LockAspectRatio = Microsoft.Office.Core.MsoTriState.msoTrue
     
        comment.Visible = False ' require user to mouse over image before seeing it.
      End Sub

    You would insert into the A1 cell with a call like:

    insertPicture(1, 1, "C:\Users\Public\Pictures\Sample Pictures\Koala.jpg")

    to insert into first cell.

  97. It would help if you also provide external setup and configuration steps because most users would try to paste it in as a macro. Where it would fail in a generic Microsoft Excel module sheet.

    I’ve also provided a VBA function (UDF) to add modules here.

    maclochlainn

    1 Jul 12 at 2:27 am

  98. dear sir

    Thanks a lot

    Best reguard

    Mostafa

    Mostafa

    29 Aug 12 at 12:33 pm

  99. Instead of a picture can you insert a .pdf file are a clickable link to a pdf file on my computer. thanks

    Christopher Mckenzie

    30 Aug 12 at 3:40 pm

  100. Very helpful. The steps worked perfectly. Thanks for posting.

    Dina

    7 Sep 12 at 10:51 am

  101. THANK YOU! I have been trying forever to find out why my excel wouldn’t allow me to do this, and it wasn’t until I read your comments in blue. THANK YOU!!!!!

    Patrick

    11 Sep 12 at 11:29 am

  102. Muitooooo Obrigado,estava ficando maluca por não conseguir inserir a imagem no comentario,voc~e me ajudou muito!!

    Valeuuu Bjuss

    Jéssica

    25 Sep 12 at 9:38 am

  103. Fantastic help – I’ve been trying to do this for months. Great work!

    Matt

    29 Sep 12 at 3:11 am

  104. thank you!!!

    mark

    7 Oct 12 at 3:40 pm

  105. Wow! what a great help! Thank you a lot, even our IT personnel couldn’t help me out with this one. Thanks again, great thought and good Karma.

    Sunita

    12 Oct 12 at 8:21 am

  106. Thank you!!!

    Jeeji

    16 Oct 12 at 8:33 am

  107. Thank you for the insert-image part!
    I am still wondering on why MS placed it so very inside. Its almost impossible to reach there via logical thinking!

    Rupali

    18 Nov 12 at 1:15 am

  108. why i dont see the option Fill Effects ?????

    moshy

    30 Dec 12 at 8:38 pm

  109. Moshy, Which version of Excel and where specifically are you clicking in the cell?

    maclochlainn

    31 Dec 12 at 9:30 am

  110. thankx its awesome….

    Paras Bhoot

    3 Feb 13 at 11:21 pm

  111. Actually this is a kludge. Microsoft should provide a method of inserting an image file (any image file) directly into a cell that allows the cell’s formatting capabilities (Autofit, Autosize, etc.) to control the image, which is nothing more than collection of data.

    Good try, but this is not the answer. I think the ball is in Microsoft’s court to provide a real, easy to use, solution. But thanks for the effort to find a work-around.

    John

    8 Feb 13 at 9:57 am

  112. John, Good luck getting them to fix it. ;-)

    maclochlainn

    8 Feb 13 at 2:55 pm

  113. that’s nice

    waseem khan

    19 Feb 13 at 5:06 am

  114. Very helpful work around indeed !

    Subrata Sinha

    26 Feb 13 at 9:50 am

  115. I can’t insert a picture in the comment.There’s no other option in formatting comment but only Font. What can I do??

    rhieu

    8 Mar 13 at 8:49 am

  116. The position of the mouse is critical to get the right context modal box.

    maclochlainn

    8 Mar 13 at 10:29 am

  117. Thanks a lot :)

    Ei Mon

    4 Apr 13 at 3:03 am

  118. This is nice to know but doesn’t solve my issue. I am attempting to add a logo to an excel version of a time sheet template. I want the logo to stay there — not flash in an out like a comment does. Is this NOT possible?? How do a i get to be there permanently in the template without recreating the entire thing in CS6?

    Thank you.

    Mitchell7993

    5 Apr 13 at 12:07 pm

  119. Wow!!! Thanks a lot

    Isha

    8 Apr 13 at 4:08 am

  120. Hi,

    I am using Excel 2007, however when I try and format the comment I only get very limited options (I only have a font tab, no colours or lines tab; and I also do not have the options for gradient et cetera.) SO help me out what to do?

    ANUP

    15 Apr 13 at 10:31 am

  121. You have to mouse over the right limit to get the other dialog box.

    maclochlainn

    15 Apr 13 at 5:53 pm

  122. I have a .xls, in which there is already an image in comment. how to get image from this comment?

    Somesh

    18 May 13 at 4:37 am

  123. I have found an API that can insert image in a cell may be it will solve your problem also if you want to try Aspose.Cells.

    fariya

    18 Jul 13 at 3:48 am

  124. great job.
    But I have a question!
    I have more than 3000 records in my excel file(2007 version)and when I tried to run the macro that inserts “image comment” on the records, the excel file bloated very badly.
    I guess excel file saves images somewhere in it, this leads to increase in size of the excel file.
    Is there any way to just link up these images to the host excel cells?
    thanks

    xan

    29 Jul 13 at 2:38 am

  125. Chetan, Not that I know about.

    maclochlainn

    29 Jul 13 at 9:57 am

  126. Thank you so much. Just saved my job! Very helpful indeed. Well done.

    gerinator

    3 Sep 13 at 11:41 am

  127. hi!

    is it possible to look up for a picture, like that of VLOOKUP?

    or any suggestions to what should i do – i want to place a picture (for example, drawing of an apple)next to the cell where “apple” is written.

    thanks a lot!

    gissa

    26 Sep 13 at 2:32 am

  128. Gissa, You can search the text value of the cell and change the text formatting to match the background, which effectively makes the search text invisible.

    maclochlainn

    30 Sep 13 at 11:09 pm

  129. Great post. Is it possible to compress the size of images that are embedded in the comments?

    Michael

    14 Oct 13 at 2:33 am

  130. Michael, Unfortunately, Microsoft doesn’t support any form of compression on these image files.

    maclochlainn

    11 Nov 13 at 2:10 am

  131. thank you

    jilani

    27 Nov 13 at 11:53 pm

  132. Good one

    JassC

    3 Feb 14 at 3:19 am

  133. Have been inserting images into cells (Excel 2013)for comments without any issue. However, I’ve recently tried to open the workbook (3 w/sheets) and after a message that a problem was encountered, the next screen shows the following:
    Removed Part: /xl/drawings/vmlDrawing2.vml part. (Drawing shape)
    Removed Part: /xl/drawings/vmlDrawing3.vml part. (Drawing shape)

    Is there any way around this? or what causes this message?
    I need the files to be opened also by users of earlier version (2003) of Excel.

    Nick

    12 Feb 14 at 6:56 pm

  134. Nick, Try saving it in Excel 97 format, which is a non-XML document type. Let me know if it fixed the problem.

    maclochlainn

    12 Feb 14 at 9:32 pm

  135. Thanks Macca (Aussie slang)
    Message “The following featueres in the workbook are not supported by earlier version of Excel. ….and so on and do forth.
    Bold:
    Minor Loss of fidelity
    A worksheet contains a sort state that uses a sort condition with a custom list. This info. will be lost..
    Options to Copy to new worksheet, continue and cancel
    None saved the images.
    Problem is that when I open the file the red tick in the cells that indicates a comment does not show in the original file anymore.

    Nick

    14 Feb 14 at 1:59 am

  136. GOSH! Thanks :)

    ming

    17 Jun 14 at 7:19 pm

  137. Thanks for the great info. I just read down, I may have missed an answer, but…

    When I share my sheet by email, users say there isnt a picture. IS this because images are linked to local files, or is it because they use an old excel version?

    Shane

    16 Jul 14 at 8:18 am

  138. Shane, yes. They’re linked to a local file. If you share the file you need to place the files in a common and consistent location.

    maclochlainn

    18 Jul 14 at 9:51 am

  139. […] How to delete such pictures? […]

Leave a Reply