Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi, it will be easy (I think). I'm creating an Excel worksheet from a C# application. When I want t insert an image in a cell of the worksheet, I use this code: Code ------------------- Excel.WorkSheet ws = (...); Excel.Range logo = ws.get_Range("A1","F10"); logo.Merge(false); logo.Select(); Image img = Image.FromFile("../images/logo.gif"); Clipboard.SetDataObject(img,false); ws.Paste(logo,"../images/logo.gif"); ------------------- After inserting the image, and if the image has less width than th cell, I want to align the image to the right. The image doesn't seem t answer to cell's horizontal or vertical alignment, so I managed to do i that way: Code ------------------- Excel.Shape shape = ws.Shapes.Item("Picture 1"); if ((shape != null)&&(shape.Width < (double)logo.Width)) { shape.IncrementLeft((float)((double)logo.Width - shape.Width)); } ------------------- The problem I had is, if there's already any picture in the worksheet obviously the one pasted will not be called "Picture 1". I always ca use the Shapes.Count to get the index of the last picture inserted an get the correct name, but it seems dirty. So the question is, how woul you do it? Maybe is a way to set an arbitrary name to the shape whe pasting? Thanks in advance -- Urotsukidoj ----------------------------------------------------------------------- Urotsukidoji's Profile: http://www.officehelp.in/member.php?userid=515 View this thread: http://www.officehelp.in/showthread.php?t=126605 Posted from - http://www.officehelp.i |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Cell reference update when copied and pasted | Excel Worksheet Functions | |||
Get a reference to the last object pasted | Excel Programming | |||
moving excel objects pasted as an image in Powerpoint | Excel Programming | |||
Reference an image in another sheet | Excel Programming | |||
reference an ole image control's .Picture filename? | Excel Programming |