Solved

Put a picture in a cell

Posted on 2011-02-11
10
225 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

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

Technology Partners: 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!

Question has a verified solution.

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

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

738 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