Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Put a picture in a cell

Posted on 2011-02-11
10
Medium Priority
?
229 Views
Last Modified: 2012-05-11
Hi,

I have an excel and between 2 textlines i have a picture.
The picture i not in the cell but on top of it.
When i take copy of the whole range i don't have the picture.
Is there a way to put the picture in a cell?

Tx
0
Comment
Question by:sonmic
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 6

Expert Comment

by:Eric Zwiekhorst
ID: 34869780
Dear Sonmic,

If you go to the picture propertys
You should select MOVE AND SIZE WITH CELLS.

Then it will copy with the selected range..
You can not put it in a cell...

kr

Eric
0
 
LVL 42

Expert Comment

by:dlmille
ID: 34869784
This should get you started.  Its not perfect and to the best of my understanding you can't insert into a picture  -  it will float, but you can put it at the top/left adjacencies...

Sub Tester()
Dim myPict As Picture

    With ActiveCell
        Set myPict = .Parent.Pictures.Insert("C:\Users\....\Pictures\Dbl click Here.jpg")
        myPict.Top = .Top
        myPict.Left = .Left
    End With

End Sub
0
 

Author Comment

by:sonmic
ID: 34869817
Insert the picture is not a problem. but when i take a copy of the range and the picture is in the middle and i do a paste the picture is not in pasted range.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 42

Expert Comment

by:dlmille
ID: 34869822
Select the range around the picture, then copy/paste - I just did it and it worked.  at least manually.

Dave
0
 
LVL 42

Expert Comment

by:dlmille
ID: 34869853
Follow this form:

Sub copyPict()

    Range("OriginalPict").Select
    Selection.Copy
    Range("Dest").Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
End Sub


see attached

Dave
copyPastePicture-r1.xlsm
0
 
LVL 45

Accepted Solution

by:
patrickab earned 2000 total points
ID: 34869960
sonmic,

It's worth noting that even if you position a picture in a cell it is not attached to that cell. The only way attach a picture to a cell is to insert a picture into a cell Comment. That can be done manually or by means of a simple macro like this:

Sub insert_pic_in_comment()
    Range("A1").AddComment
    Range("A1").Comment.Visible = True
    Range("A1").Comment.Text Text:="Sunset" & Chr(10) & ""
    Range("A1").Comment.Shape.Fill.UserPicture _
        "C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Sunset.jpg"
End Sub

Correct the path to the picture to suit your requirements.

Patrick
0
 
LVL 6

Expert Comment

by:Eric Zwiekhorst
ID: 34870031
Dear Patrick,

I did try it (Excel 2003) from the comment itself but did not succeed.

I did run the macro and to my supprise it was there.

Never to old to learn...


Kind regards


Eric
0
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 34870155
Eric,

It can be done manually too:
Right-click and Format Comment
Select the Colors and Lines tab
Click the Color: dropdown and choose Fill Effects... at the bottom
Switch to picture tab and choose your picture.

HTH
Rory
0
 
LVL 45

Expert Comment

by:patrickab
ID: 34871348
sonmic - Thanks for the grade - Patrick
0
 
LVL 45

Expert Comment

by:patrickab
ID: 34871710
Eric,

It's rare that I can tell the old hands anything at all!

Patrick
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question