Solved

Put a picture in a cell

Posted on 2011-02-11
10
219 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 45

Accepted Solution

by:
patrickab earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
sonmic - Thanks for the grade - Patrick
0
 
LVL 45

Expert Comment

by:patrickab
Comment Utility
Eric,

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

Patrick
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

771 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

10 Experts available now in Live!

Get 1:1 Help Now