Executing WIN32OLE program


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Executing WIN32OLE program
# 1  
Old 08-19-2010
Executing WIN32OLE program

Hello,

Please help me out to execute this perl program:
Code:
#!/usr/bin/perl -w

use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';

$Win32::OLE::Warn = 3;                                # die on errors...

# get already active Excel application or open new
my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
    || Win32::OLE->new('Excel.Application', 'Quit');  

# open Excel file
my $Book = $Excel->Workbooks->Open("u:/file.xls"); 
my $Book1 = $Excel->Workbooks->Open("u:/v3.xls");


# select worksheet number 1 (you can also select a worksheet by name)
my $Sheet = $Book->Worksheets(1);
my $Sheet1 = $Book1->Worksheets(1);
my $val1;
my $cnt=0;
my $line;

foreach my $row (1..3000)
{
 foreach my $col (1)
 {
  my $val;
  next unless defined $Sheet->Cells($row,1)->{'Value'};
  $val = $Sheet->Cells($row,1)->{'Value'};
  #findl($val);
  for($cnt=1;$cnt<=65536;$cnt++){
    $val1 = $Sheet1->Cells($cnt,1)->{'Value'};
    if ((defined $val1) && (index($val1,$val) != -1)){
      $line =$cnt if (!defined $line);
      $Sheet->Cells($row,2)->{'Value'}=1;
      last;
    }
        
 }
}
}
$Book->SaveAs ("u:/new_name.xls") ;
# clean up after ourselves
$Book->Close;
$Book1->Close;

What is the procedure to execute this script which uses WIN32 OLE
# 2  
Old 08-19-2010
Quote:
Originally Posted by suvenduperl
...
...
Code:
#!/usr/bin/perl -w
 
use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';
 
$Win32::OLE::Warn = 3;                                # die on errors...
 
# get already active Excel application or open new
my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
    || Win32::OLE->new('Excel.Application', 'Quit');  
 
# open Excel file
my $Book = $Excel->Workbooks->Open("u:/file.xls"); 
my $Book1 = $Excel->Workbooks->Open("u:/v3.xls");
 
 
# select worksheet number 1 (you can also select a worksheet by name)
my $Sheet = $Book->Worksheets(1);
my $Sheet1 = $Book1->Worksheets(1);
my $val1;
my $cnt=0;
my $line;
 
foreach my $row (1..3000)
{
 foreach my $col (1)
 {
  my $val;
  next unless defined $Sheet->Cells($row,1)->{'Value'};
  $val = $Sheet->Cells($row,1)->{'Value'};
  #findl($val);
  for($cnt=1;$cnt<=65536;$cnt++){
    $val1 = $Sheet1->Cells($cnt,1)->{'Value'};
    if ((defined $val1) && (index($val1,$val) != -1)){
      $line =$cnt if (!defined $line);
      $Sheet->Cells($row,2)->{'Value'}=1;
      last;
    }
 
 }
}
}
$Book->SaveAs ("u:/new_name.xls") ;
# clean up after ourselves
$Book->Close;
$Book1->Close;

What is the procedure to execute this script which uses WIN32 OLE
Looks like a Perl script to me, so I guess you execute it like you would a Perl script.

tyler_durden
# 3  
Old 08-19-2010
It is throwing this error..........

Code:
Can't locate Win32/OLE.pm in @INC (@INC contains: /usr/lib/perl5/5.8.0/cygwin-mu
lti-64int /usr/lib/perl5/5.8.0 /usr/lib/perl5/site_perl/5.8.0/cygwin-multi-64int
 /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl .) at ./newfile.pl line
 4.
BEGIN failed--compilation aborted at ./newfile.pl line 4.

# 4  
Old 08-19-2010
Quote:
Originally Posted by suvenduperl
It is throwing this error..........

Code:
Can't locate Win32/OLE.pm in @INC ...

Well, the error message is very clear, isn't it ?

tyler_durden
# 5  
Old 08-19-2010
Now i am able to create the executable of this script....
But i am unable to get anyoutput....
after executing the exe
where may be the problem
# 6  
Old 08-19-2010
You turned a perl script into a .exe? That doesn't really work. (There's utilities to do it, but they're all awful at it.) Why did you think that would help? The problem, like the error message flat-out tells you, is the missing OLE module, install it.
# 7  
Old 08-19-2010
You don't have to really convert perl scripts to a binary form. You can however "bind" them inside an executable like in this project project: Openkore.com &bull; Index page. I have also tried compiling with the whole scripts included as well. The only problem is that the compiler is only usable in trials. The program used is perlapp from activeperl.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Error in executing the C program

Hello Friends, I have written a code for the unisex bathroom which makes a policy that when a woman is in the bathroom only other women may enter, but not men, and vice versa. This program consists of four functions which a user defines but these functions are not properly working while... (4 Replies)
Discussion started by: Ravi Tej
4 Replies

2. Shell Programming and Scripting

AWK Program Not Executing On Linux with KSH

Overview: I have an AWK program that parses thru a database backup server log file and outputs ths following parameters SRNO DATE : TIME SIZE IN(KB) DATABASE NAME DUMP TYPE 1 May 16 2012: 13:30:00 6874 TestDB database 2 May 16 2012: 13:30:44 11462 master database Problem: This program has... (5 Replies)
Discussion started by: JolietJake
5 Replies

3. UNIX for Dummies Questions & Answers

executing a different program

What system calls or commands do I need to use in order to execute a different program from an already running process? (1 Reply)
Discussion started by: justOne21
1 Replies

4. Shell Programming and Scripting

Executing a Java Program

I am entirely new to shell scripting and would like to create a script to execute a java program called Main. I've already compiled it and placed the .java and .class files at /root/javaTest. Next I made a shell script that simply contained: java /root/javaTest/Main . I made the script... (2 Replies)
Discussion started by: hypnotic_meat
2 Replies

5. Solaris

How to know the size of the program currently executing in memory

hey everybody, i am currently working on solaris 10 os on a m5000 server. my problem is when i want the exact size of a program in execution, i am unable to do it. earlier i thought the RSS field of prstat but because of its large size it cant be the size. pmap -x shows some output but it includes... (2 Replies)
Discussion started by: aryansheikh
2 Replies

6. Programming

Trubble in executing the cpp program...

I wrote a code like this....... #include <iostream> #include <stdio.h> #include <mysql.h> #include <string.h> #include <stdlib.h> using namespace std; #include "Connection.h" int main() { char *Host = (char *)"localhost"; char *Database =(char *)"sachin"; char... (3 Replies)
Discussion started by: ps_sach
3 Replies

7. Programming

after executing execvp()... program hangs up

Hi , I m actually trying to implement pipes program,but after executing the execvp(),my program is getting hanged up :mad: Actaully i m getting the desired output expected from execvp()...but once results are displayed on the output screen ,program is getting hanged up values of... (3 Replies)
Discussion started by: Crab
3 Replies

8. Programming

Executing an .ec program in different informix versions

Hi all, I tried writing an .ec program connecting to informix database from solaris platform Sun 5.7 informix version that i had to used when i compiled the program was 9.21.UC3 the binary when i ported solaris box with informix version 9.40.UC5 i am unable to run that i am encountering... (0 Replies)
Discussion started by: matrixmadhan
0 Replies

9. UNIX for Dummies Questions & Answers

executing the su command from a java program.

Say in unix (AIX) m/c, I am logged in with s1 user and want to start process p1 with user credentials of s2. I can do manually in this way: #su - s2 #enter password for s2> somePassword $ p1 But all this I have to do through a java program. How to pass the password through program. One... (1 Reply)
Discussion started by: shailendrat
1 Replies

10. Programming

executing a program within a program

Read the title: how do i do it? (4 Replies)
Discussion started by: Gekko
4 Replies
Login or Register to Ask a Question