Solved

Put a picture in a cell

Posted on 2011-02-11
10
220 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 41

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
 
LVL 41

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 41

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 45

Accepted Solution

by:
patrickab earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

920 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now