Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Insert image into cell using C# and Excel interop??

I'm trying to insert a bitmap from the harddrive into a cell of a
worksheet and can't seem to find anything in MSDN or on the net.

I'm creating Excel (version 2003/11) from within a C# application
ExcelApp = new Microsoft.Office.Interop.Excel.Application();

I recorded a macro and inserted a jpg into a cell and the code
that Excel generated was the following

Range("F20").Select
ActiveSheet.Pictures.Insert("C:\Logo transparent.gif").Select

In my C#/Winforms application I have code that looks like this

currentSheet = (Excel.Worksheet)ExcelApp.Workbooks[0].Sheets[0];
Excel.Range range = currentSheet.get_Range("A1", "A1");
range.Select();

currentSheet.Pictures does not have any methods?
I've looked at the range object and the WorkSheet object and haven't
figured out how to insert a bitmap from a file

I've seen code that uses the clipboard like this
Image oImage = Image.FromFile(_stLOGO);
System.Windows.Forms.Clipboard.SetDataObject(oImag e,true);
ThisSheet.Paste(oRange,_stLOGO);

do I have to use the clipboard

I did the same in Word with one line of code
WordApp.Selection.InlineShapes.AddPicture(
Path.GetDirectoryName(System.Windows.Forms.Applica tion.ExecutablePath) +
Path.DirectorySeparatorChar + "Logo.gif",
ref oFalse, ref oTrue, ref oMissing);

thanks
mike
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
insert an image based on a cell value brig239 New Users to Excel 1 June 3rd 09 07:10 PM
Export image from Excel using interop Ksım GÜLCAN Excel Programming 0 July 29th 06 11:44 AM
How do I insert an image into a specific cell within a protected . Scott Peebles Excel Discussion (Misc queries) 1 January 7th 05 01:14 AM
conditional insert image in a cell Bob Excel Programming 0 November 5th 04 04:49 PM
How to insert a bitmap image into a Excel Cell? Sundarraj Natarajan[_2_] Excel Programming 0 July 29th 04 04:23 PM


All times are GMT +1. The time now is 02:22 PM.

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"