Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
mjohnson
 
Posts: n/a
Default How to add an image to a worksheet programmatically

I am trying automate adding a picture to an excel sheet using JScript
(I would imagine the language shouldn't matter that much). After doing
quite a bit of research I tried writing the following code but I get an
error saying that the 'Pictures' collection is null or not an object.
I can't seem to figure out what I should be doing:

var book = new ActiveXObject("OWC10.Spreadsheet");
var sheet = book.Worksheets[1];
var range = sheet.Range("A1");

range.Activate();
sheet.Pictures.Add( PATH_TO_LOGO_BMP );

Any suggestions? thanks for your help!

  #2   Report Post  
Ron de Bruin
 
Posts: n/a
Default

Use something like this

ActiveSheet.Shapes.AddPicture "C:\Data\Skate.jpg", msoTrue, _
msoFalse, 100, 100, 100, 50



--
Regards Ron de Bruin
http://www.rondebruin.nl



"mjohnson" wrote in message oups.com...
I am trying automate adding a picture to an excel sheet using JScript
(I would imagine the language shouldn't matter that much). After doing
quite a bit of research I tried writing the following code but I get an
error saying that the 'Pictures' collection is null or not an object.
I can't seem to figure out what I should be doing:

var book = new ActiveXObject("OWC10.Spreadsheet");
var sheet = book.Worksheets[1];
var range = sheet.Range("A1");

range.Activate();
sheet.Pictures.Add( PATH_TO_LOGO_BMP );

Any suggestions? thanks for your help!



  #3   Report Post  
mjohnson
 
Posts: n/a
Default

Thanks for your response but it still doesn't work. It seems that
'Shapes' isn't a valid member either. This is what I tried:

sheet.Shapes.AddPicture(PATH_TO_LOGO,true,false,10 0,100,100,50);

Not sure if the problem is 'ActiveSheet' or not. I realize that
ActiveSheet is valid in VBA, but I tried 'book.ActiveSheet' but that
didn't work either. Using the ObjectBrowser is less than satisfactory
(it doesn't even give you a view into the Cell object). It's very
frustrating trying to find documentation on how to use the Excel object
effectively. A lot of guess work....

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
Copy from worksheet to another x times Union70 Excel Discussion (Misc queries) 0 March 7th 05 09:03 PM
Weekly Transaction Processing Ralph Howarth Excel Worksheet Functions 4 January 19th 05 05:37 AM
Indirect reference from one worksheet to another Bill Sturdevant Excel Worksheet Functions 2 December 17th 04 01:23 PM
Reference Data in Moved Worksheet tommcbrny Setting up and Configuration of Excel 1 December 1st 04 06:49 PM
Worksheet name and Backward compatibility Rich Excel Discussion (Misc queries) 3 November 30th 04 06:10 PM


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