Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA code for sizing/showing pictures Secret Squirrel Excel Discussion (Misc queries) 1 August 28th 08 04:43 AM
VB.NET & Excel, Inserting and Sizing Pictures (An Answer) eBob.com[_3_] Excel Programming 0 September 6th 07 06:52 PM
Inserting pictures into cells (Excel 2007) Max Excel Programming 6 August 31st 07 04:34 PM
Inserting pictures in Excel 2003 jawone48 Excel Discussion (Misc queries) 6 August 11th 07 06:17 AM
Excel memory and speed when inserting pictures ??? Greg Wilson Excel Programming 2 September 14th 05 09:01 AM


All times are GMT +1. The time now is 09:58 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"