Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VB.NET & Excel, Inserting and Sizing Pictures (An Answer)
Here's how I insert and size pictures in an Excel spreadsheet which I create
via a VB.NET program (commentary follows): 'add thumb nail objSheet.Rows(XLRow.ToString).rowheight = mpThumbNailHeight / 7 objSheet.Range("S" & XLRow.ToString).Select() objSheet.Pictures.insert(mpThumbNailLoc) 'size thumb nail - because they often end up different sizes although they all ' look the same size on the web site Dim objsr As Excel.ShapeRange 'since there was no picture in the headings row we have to reduce XLRow in the following by 1 objsr = objSheet.Shapes.Range("Picture " + (XLRow - 1).ToString) objsr.Height = 110.25 objsr.Width = 65.25 I had a hard time finding out how to do the above, so I wanted to share it. A key piece of the puzzle was finding this web page: http://msdn2.microsoft.com/en-us/lib...ce.interop.exc... I don't know if I should have used that web page since what I am doing has nothing to do with "aspx", whatever that is, but it had the info I needed to get my pictures sized. Helpful advice, which I received on microsoft.public.excel.programming, was to turn on Excel macro recording and then go thru the manual steps to do whatever it is you want to do in a program, and then to look at the resulting macro code. But the result, if what you need is VB.NET code, only gets you going in the right direction. At least that was my experience when it came to sizing pictures. Some comments on the code above ... The width of the column in which I am putting pictures is set once after the spreadsheet is created 'make thumbnail column wide enough objSheet.Columns("S").Select() objSheet.Cells.ColumnWidth = 12 Also, this is a "work in progress". I don't know at the moment why I use a constant for objsr.Height when I have mpThumbNailHeight. Hope this is helpful to someone someday. Bob |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
VBA code for sizing/showing pictures | Excel Discussion (Misc queries) | |||
VB.NET & Excel, Inserting and Sizing Pictures (An Answer) | Excel Programming | |||
Inserting pictures into cells (Excel 2007) | Excel Programming | |||
Inserting pictures in Excel 2003 | Excel Discussion (Misc queries) | |||
Excel memory and speed when inserting pictures ??? | Excel Programming |