ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Graphic within Cell Comment (revisited) (https://www.excelbanter.com/excel-discussion-misc-queries/68001-re-graphic-within-cell-comment-revisited.html)

Debra Dalgleish

Graphic within Cell Comment (revisited)
 
There's code here that will insert the selected picture into a comment
in the active cell. You could modify it slightly, to paste the clipboard
contents at the start of the code:

http://www.contextures.com/xlcomments03.html#Picture

No Spam wrote:
A couple of years ago some kind (and very clever) person posted the
following code that allows me to paste a graphic within a cell
comment. It works very, very well. I would like to know if it's
possible to modify the code so it will take the graphic from the
current content of the Windows clipboard instead of looking for a
file?

Thanks!

/Lac/


Sub PIC()

Dim myPictureName As Variant

myPictureName = Application.GetOpenFilename _
(filefilter:="Picture
Files,*.jpg;*.bmp;*.tif;*.gif")


If myPictureName = False Then
Exit Sub 'user hit cancel
End If


With ActiveCell
'delete existing comments
If .Comment Is Nothing Then
'do nothing
Else
.Comment.Delete
End If
.AddComment
With .Comment.Shape
.Fill.Transparency = 0#
.Line.Weight = 0.75
.Line.DashStyle = msoLineSolid
.Line.Style = msoLineSingle
.Line.Transparency = 0#
.Line.Visible = msoTrue
.Line.ForeColor.RGB = RGB(0, 0, 0)
.Line.BackColor.RGB = RGB(255, 255, 255)
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(255, 255, 255)
.Fill.BackColor.SchemeColor = 80
.Fill.UserPicture myPictureName
End With
End With

End Sub



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html



All times are GMT +1. The time now is 12:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com