comment picture to userform

casinsh

New Member
Joined
Dec 30, 2011
Messages
3
Hi there! i would like to know if its possible to get image from comment and add it to userform?

at this moment i have added image to comment and user form, but now i have to get that image to other form. is it possible at all?
Private Sub CommandButton1_Click()

Dim Pict
Dim ImgFileFormat As String
Dim cmt As Comment
Range("a1").Comment.Delete
Set cmt = Range("a1").AddComment

cmt.Text Text:=""

ImgFileFormat = "Image Files (*.jpg),others, png (*.png),*.png"

Pict = Application.GetOpenFilename(ImgFileFormat)
If Pict = False Then End

UserForm1.Image1.Picture = LoadPicture(Pict)
Image1.PictureSizeMode = fmPictureSizeModeStretch


With cmt.Shape
.Fill.UserPicture Pict
End With

End Sub

or is there any other way to get picture to sheets cell and later at any time that same picture to other userform picturebox

if misunderstood, ask whats needed

thanks
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Whilst I don't think you can get at the picture once it is loaded into the comment you can create an image copy of the comment using the CopyPicture method of the comments shape object.

You can the use Stephen Bullen's PastePicture code to load a image control on a userform with the copied image.
http://www.oaltd.co.uk/Excel/Default.htm

This code example will copy a comment. You just need to incorporate Stephen's code to populate the image control.

Code:
Private Sub CommandButton1_Click()

    Dim objComment As Comment
    Dim shpTemp As Shape
    
    Set objComment = Range("C5").Comment
    Set shpTemp = objComment.Shape
    
    Application.ScreenUpdating = False
    objComment.Visible = True
    shpTemp.CopyPicture xlScreen, xlPicture
    objComment.Visible = False
    Application.ScreenUpdating = True
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,972
Messages
6,128,027
Members
449,414
Latest member
sameri

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top