PERL Win32::OLE Inserting Picture in Excel


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting PERL Win32::OLE Inserting Picture in Excel
# 1  
Old 09-30-2010
PERL Win32::OLE Inserting Picture in Excel

I am trying to insert a picture into a worksheet in Excel using Perl the following is the code

Code:
use Win32::OLE;
use Win32::OLE::Const "Microsoft Excel";
use Win32::OLE qw(in with);
# Initiate Excel application
$Excel = Win32::OLE->new('Excel.Application', 'Quit');
$Excel->{Visible} =1;

# Create workbook and first worksheet
$Excel->{SheetsInNewWorkbook} = 1;
$Book = $Excel->Workbooks->Add;
$Sheet = $Book->Worksheets(1);
$Sheet->{Name} = 'Picture';
#$Sheet->Shapes->AddPicture("test.bmp",msoCFalse,msoCTrue,1,1,500,500);

I excuted the same code for inserting the picture in a VBA macro and it worked. I am using Excel 2007. I do not know what the issue is I can insert every object except for a picture.

Any one know how to insert the picture in Excel 2007 using Win32::OLE?

Thanks
# 2  
Old 10-01-2010
I figured it out.... just replace the double quotes around the file with single quotes. The code should look like this

Code:
use Win32::OLE;
use Win32::OLE::Const "Microsoft Excel";
use Win32::OLE qw(in with);
# Initiate Excel application
$Excel = Win32::OLE->new('Excel.Application', 'Quit');
$Excel->{Visible} =1;

# Create workbook and first worksheet
$Excel->{SheetsInNewWorkbook} = 1;
$Book = $Excel->Workbooks->Add;
$Sheet = $Book->Worksheets(1);
$Sheet->{Name} = 'Picture';
#$Sheet->Shapes->AddPicture('D:\test\est.bmp',msoCFalse,msoCTrue,1,1,500,500);

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Inserting values into database from an excel

Hi, I have a requirement where I have an excel sheet with the below values COL1 COL2 COL3 Germany URGENT NORMAL I want to cut the values of this excel in such a way that I get the values and pass it to an insert statement update tbfin set... (2 Replies)
Discussion started by: venkidhadha
2 Replies

2. Shell Programming and Scripting

Perl syntax and html ole parsing

Hi gurus I am trying to understand some advanced (for me) perl constructions (syntax) following this tutorial I am trying to parse html: Using Mojo::DOM | Joel Berger say "div days:"; say $_->text for $dom->find('div.days')->each; say "\nspan hours:"; say $_->text for... (1 Reply)
Discussion started by: wakatana
1 Replies

3. Programming

Perl OLE Selection property iteration in cycle

Hi gurus, i am trying to write simple perl script using win32 ole which will iterate over all M$ word paragraphs (any text that ends with a hard return) and print only those paragraphs that matches the specified condition. The problem is that I need to access font size property. It seems to me that... (0 Replies)
Discussion started by: wakatana
0 Replies

4. Shell Programming and Scripting

win32 ole in deepr details in perl

Hello Gurus, I am begginer in perl. I would like to ask several questions, some related to perl and its syntax but most will be regarding to WIN32 OLE. My main goal is to develop script that will check word document structure (return some information) and make some changes in this document (if it... (0 Replies)
Discussion started by: wakatana
0 Replies

5. Shell Programming and Scripting

Details about WIN32::OLE

Hi all, Is win32::OLE module is applicable in linux system??? from my understanding it is not possible..because we have to use some tools for that..for more info refer this website http://oclug.on.ca/archives/oclug/2001-July/008100.html (1 Reply)
Discussion started by: kavi.mogu
1 Replies

6. Shell Programming and Scripting

MS Outlook + Win32::OLE

Hey guys, I'm trying to go through my emails in Outlook until I find an email with a certain subject line. I am able to send emails with no problem, but reading emails and their properties (From, Subject, etc.) is my main problem. Basically, I don't know where to start and using search engines... (2 Replies)
Discussion started by: kooshi
2 Replies

7. Shell Programming and Scripting

OLE ERROR in perl

Hello All, I have executed one script where i am getting this error,what may be the reason..... please help me out. OLE exception from Microsoft Excel Win32::OLE(0.1403) error 0x800a03ec in METHOD/PROPERTYGET "open" (1 Reply)
Discussion started by: suvenduperl
1 Replies

8. Shell Programming and Scripting

Spell Check in MS Word using PERL OLE

Hi, I am trying automate couting number of spell and typo errors in MS Word document using perl script. In perl script, i am using Win32::OLE module of perl to read MS word document. Can anybody tell me are there any modules available in perl which can be imported into my script to... (0 Replies)
Discussion started by: 123an
0 Replies

9. Windows & DOS: Issues & Discussions

Perl in Win32

Dear, Did anybody knnow how to run the Perl script or whatever mean for testing the script in Windows? (1 Reply)
Discussion started by: Paris Heng
1 Replies

10. Shell Programming and Scripting

Win32::OLE open excel file as read only

I am using Win32::OLE to write a perl script which opens an excel file. That excel file is password protected and everytime i run that script dialog box pops up and I have to click on Read-Only then my script executes. Is there any way I can specify the readonly attribute in my code so i dont have... (0 Replies)
Discussion started by: dguy
0 Replies
Login or Register to Ask a Question