473,583 Members | 2,875 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(X LRow.ToString). rowheight = mpThumbNailHeig ht / 7
objSheet.Range( "S" & XLRow.ToString) .Select()
objSheet.Pictur es.insert(mpThu mbNailLoc)

'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.ShapeRang e

'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...el(VS.80).aspx

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.publi c.excel.program ming, 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.Column s("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 mpThumbNailHeig ht.

Hope this is helpful to someone someday.

Bob


Sep 6 '07 #1
0 1505

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1310
by: Oded | last post by:
Hi, I'm trying to export an ASP based report to Excel while preserving its display properties. I've added: Response.ContentType="application/vnd.ms-excel", and it works fine for several clients. For other clients it displays an emptry excel sheet. I'm not sure, but i think it has something to do with the excel version installed on clients -...
3
1711
by: Mike Caputo | last post by:
I'm setting up an auto e-mailer in VB.NET to send daily reports to clients. I have the main part of that all set, but there are a couple of things I'm not quite sure on: 1) I'll be sending about 10-20 reports, and am not quite sure how to queue them. The reports are anywhere from 500K to 3MB, so I imagine this is fairly important. Does...
6
2397
by: Mark Rae | last post by:
Hi, My client has asked me to provide a "quick and dirty" way to export the contents of a DataGrid to both Excel for analysis and Word for editing and printing, so I'm investigating client-side automation. N.B. the environment is a totally enclosed intranet, all the client machines have WinXP, IE6 and Office Pro 2003 with all the latest...
0
1746
by: dt | last post by:
I downloaded Microsoft Office 2003 Reference Schemas from: http://www.microsoft.com/downloads/details.aspx?familyid=fe118952-354... Then I tried to use JAXB on them, specifically excel.xsd and excelss.xsd. The first one passes OK, but doesn't contain Worksheet element, which is the root element for Excel 2003 documents saved as XML. The...
0
1501
by: AlexNunley | last post by:
I am trying to dump data from an access query into excel so I can pretify it. I found sample code from an old access 97 book (The version of access in use)and tinkered it into working. Well sort of. The error I get is usually a "Object Required" error, and it highlights the bolded section below. I have been through this thing backwards and...
4
4390
by: Suzette | last post by:
I have an excel file that automatically updates when opened, pulling information from an Access database into into various pivot tables. I created a macro in Access to perform various necessary functions with the data. I want to be able to open an Access form that I created, and then hit a button that will run the macros and that will open...
5
2399
by: Ty | last post by:
I'm new to SQL but not Excel I was given a Excel spreadsheet with Employee names. I have a large database with a Personal Table with Employee names and a whole list of other tables that I'm used to running queries. I'm still new to queries. I can run queries using the Pers_Table with employees and other tables. How can I import the...
2
12141
catatonicalvin
by: catatonicalvin | last post by:
I'm working right now C# to Excel. How do i insert image at left and right header, through c# code? Please refer to code: Excel.Application xl = new Excel.ApplicationClass(); Excel.Workbook wb = xl.Workbooks.Add(Excel.XlWBATemplate.xlWBATWorksheet); Excel.Worksheet ws = (Excel.Worksheet)wb.ActiveSheet; ...
0
7888
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7811
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8314
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8185
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6571
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5689
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5366
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1416
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1147
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.