Getting a cell's position in points?

Tarheel

Board Regular
Joined
Jul 30, 2002
Messages
158
Hi all,

I am using the AddPicture method (Shapes) to insert a bunch of images into a worksheet for a report. The AddPicture method requires a parameter (Left,Top) for the position to insert the picture, which is measured in points relative to the upper-left corner of the document.

I want to insert these pictures into cells, and I do not know how to calculate the relative position of a cell from the upper-left corner of the document. Is there a way to do this?

Thanks,
Richard
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Richard -

You can't insert a picture or other object into a cell, but you can float it in the drawing layer above the worksheet, aligned with cells.

Expanding on the help files' example, and assuming B2 is large enough:

Code:
With ActiveSheet
    .Shapes.AddPicture "c:\microsoft office\clipart\music.bmp", _
        True, True, .range("B2").left, .range("B2").Top, _
        .Range("B2).Width, .Range("B2").Height

You can substitute any range for "B2", such as a larger address "B2:F20", a named range "MyRange", or a VBA range variable rngPicture.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
http://www.geocities.com/jonpeltier/Excel/index.html
_______
 
Upvote 0
Jon,

Thank you so much for the quick reply. It works fabulously, of course.

I did know that you cannot insert an image into a cell, I meant that I wanted the image aligned with the cell. Thanks for pointing that out and reminding me.

Best regards,
Richard
 
Upvote 0
Hello to all :)
i need to add one image on one excel file ...
but i create it in a asp web page ,
and then i want people can save it with the image

i use some instruction like this :

Code:
Response.ContentType = "application/vnd.ms-excel" 
FileName = "NAME-(" & Day(Date) & "-" & Month(Date) & "-" & Year(Date) & " " & Hour(Now) & Minute(Now) & ").xls"
Response.AddHeader "Content-Disposition", "inline; filename=" & FileName
Response.Write "<html xmlns:x=""urn:schemas-microsoft-com:office:excel"">"


actually the image it is a simple link to an Url

Code:
<img src= <%=url%> alt="<%=alt_text%>">

:rolleyes:
how i can use (if i can) .AddPicture to add it in a binary format ?
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,279
Members
449,075
Latest member
staticfluids

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