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 Inserted Picture Ends Up in Wrong Cell

I've spent about 5 hours tonight trying to find out how to insert a picture
into a cell using VB.NET. It turns out I was finding code which (ALMOST)
works but Intellisense kept telling me that ActiveSheet does not have a
Pictures method. When, in desperation, I finally decided to just try to run
the code despite the Intellisense warning, it worked!, ALMOST.

The almost part is that the picture ends up in the wrong cell. I use the
following code ...

objSheet.Range("A1").Select()
objSheet.Pictures.insert("e:\temp\jpeg samples\s_01.jpg")

but the picture ends up in row 4, column B. I've tried other arguments to
the Range method but the picture always ends up in row 4, column B.

Note that this is not VBA. I am using VB.NET and an Interop Assembly
(Microsoft Excel 12.0 Object Library / Imports Excel =
Microsoft.Office.Interop.Excel).

I'd sure appreciate any thoughts anyone might have. The next thing that
I'll have to do is to get the picture sized correctly, if you'd care to
offer any help in that area.

Thanks, Bob


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VB.NET Inserted Picture Ends Up in Wrong Cell


I don't know VB Net but I will try to answer your question. The inser
picture method you can't specify the location. You have to insert th
picture then move it using the picture propertie
.left,.width,.top,.height.

The .left,.top,.top., height are pixel locations that are equivalen
for pictures (shapes) and cells. shapes are not part of the cel
structure and actually sit ontop of the worksheet (not in the sheet).

My VB Net coe may not work. Make changes as required

from
objSheet.Pictures.insert("e:\temp\jpeg samples\s_01.jpg")
to
set obj = objSheet.Pictures.insert("e:\temp\jpeg samples\s_01.jpg")
obj.left = range("B4").left
obj.width = range("B4").width
obj.top = range("B4").top
obj.height = range("B4").heigh

--
joe
-----------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=22
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=14984

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
how do I associate an inserted picture with its row? [email protected] Excel Discussion (Misc queries) 1 October 22nd 09 07:22 AM
Copy from one worksheet to another is inserted into wrong cell Markus F. Robinson Excel Discussion (Misc queries) 0 January 22nd 06 09:31 PM
Inserted picture name DaveJones Excel Programming 7 December 8th 05 02:36 PM
picture 34 was inserted by excel? sophy2 Excel Discussion (Misc queries) 1 October 6th 05 02:23 PM
How to write in cell, in Excel, under the inserted picture. Pictu. Max Excel Discussion (Misc queries) 2 March 22nd 05 02:31 PM


All times are GMT +1. The time now is 04:39 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"