473,770 Members | 6,158 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Opening Password Protected Excel file using Win32:OLE in Perl

33 New Member
Hi,
I need help to open a password protected excel file in perl using Win32:OLE.
when I tried to open file in normal way at the time of program execution it is prompting me to enter password.
I am giving the script i used for opening excel file..
So i want to know how to provide password parameter while opening the file.
Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use Win32::OLE;
  3. use Win32::OLE::Const 'Microsoft Excel';
  4. use Win32::OLE::Variant qw(:DEFAULT nothing);
  5. $Win32::OLE::Warn = 3;
  6.  
  7. my $excelObj;
  8. my $fileName = "D:\\Mohan\\test.xls";
  9. $excelObj = Win32::OLE->new('Excel.Application', 'Quit');
  10. $excelObj->{'DisplayAlerts'} = 0;
  11. $excelObj->{'AskToUpdateLinks'} = 0;
  12. $excelObj->{'Visible'} = 0;
  13. my $bookObj;
  14. # If there is any problem in accessing files then auto mail will be sent.       
  15. eval
  16. {
  17.     $bookObj = $excelObj->Workbooks->Open($fileName);
  18. };
  19. if($@)
  20. {
  21.     my $msg = "";
  22.     die "A problem was encountered when accessing the file $fileName \n";
  23. }
  24. my $sheetObj = $bookObj->Worksheets(1);
  25. my $val    = $sheetObj->Cells(10,3)->{'Value'};
  26. print "Value == $val\n";
  27. $excelObj->ActiveWorkbook->Close(0);
  28. $excelObj->Quit();
  29.  
Thanks in Advance.
Dec 10 '07 #1
1 6207
numberwhun
3,509 Recognized Expert Moderator Specialist
Hi,
I need help to open a password protected excel file in perl using Win32:OLE.
when I tried to open file in normal way at the time of program execution it is prompting me to enter password.
I am giving the script i used for opening excel file..
So i want to know how to provide password parameter while opening the file.
Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use Win32::OLE;
  3. use Win32::OLE::Const 'Microsoft Excel';
  4. use Win32::OLE::Variant qw(:DEFAULT nothing);
  5. $Win32::OLE::Warn = 3;
  6.  
  7. my $excelObj;
  8. my $fileName = "D:\\Mohan\\test.xls";
  9. $excelObj = Win32::OLE->new('Excel.Application', 'Quit');
  10. $excelObj->{'DisplayAlerts'} = 0;
  11. $excelObj->{'AskToUpdateLinks'} = 0;
  12. $excelObj->{'Visible'} = 0;
  13. my $bookObj;
  14. # If there is any problem in accessing files then auto mail will be sent.       
  15. eval
  16. {
  17.     $bookObj = $excelObj->Workbooks->Open($fileName);
  18. };
  19. if($@)
  20. {
  21.     my $msg = "";
  22.     die "A problem was encountered when accessing the file $fileName \n";
  23. }
  24. my $sheetObj = $bookObj->Worksheets(1);
  25. my $val    = $sheetObj->Cells(10,3)->{'Value'};
  26. print "Value == $val\n";
  27. $excelObj->ActiveWorkbook->Close(0);
  28. $excelObj->Quit();
  29.  
Thanks in Advance.
To tell you the truth, I am not really sure how you would do this as I haven't played with Excel spreadsheets with Perl. I did check CPAN and it looks like the Spreadsheet::Pa rseExcel module has "ToDo" plans of implementing something to access protected Excel spreadsheets. It may behoove you to contact the author and see where he is with that. If he hasn't touched it, then if you get a solution in place to do so, it would be a good chance to publish either your first or another Perl module.

Regards,

Jeff
Dec 10 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
4446
by: harshan | last post by:
Hi I am trying to read required worksheet from excel file using perl with module spreadsheet::parseexcel and spreadsheet::writeexcel but I am unable to read it, the error I am getting is subroutine &main::worksheet not found. any help regarding this will be greatly appriciated. Harshan
2
6106
by: Vinay Gupta | last post by:
Hi, In a Perl to Tcl conversion project, I am planning to use the following Tcl extensions as a replacement for some Perl libraries. My development environment is Windows. Win32::OLE --> "DDE" or "OpTcl" LWP::UserAgent, HTTP::Request --> "Scotty" Net::Telnet --> "Expect" ('spawn telnet') I have used Expect but haven't used Scotty, DDE or OpTcl before.
2
6180
by: usenet | last post by:
Problem installing Win32::OLE under Cygwin. I have searched the web and found little documentation on installation procedure. Please help. I'd like to get Win32::OLE working under cygwin. Cygwin perl 5.8.6-4 Windows XP SP1
1
8911
by: Kriston Scott | last post by:
I would like to know how to sort the rows in an Excel file, using Perl.
8
15689
by: VinayKumarParakoti | last post by:
Hi all, I am new to this site and this is my first post. But this issue is of high priority. I am trying to print pdf file in browser using perl script. Onclick on hyperlink a child window is opened along with through javascript i have redirected to perl.In perl i am doing something like this, print "Expires -1\n\n"; print "Content-Disposition: Attachmet; filename="Path of the file";
3
4016
by: rahatekarabhijeet | last post by:
I want to create excel sheet using perl, i had installed all the necessary modules from CPAN. The perl program i taken from CPAN itself it is given below, #!/usr/bin/perl -w use warnings; use strict; use Excel::Template; # Create the Excel template my $template = Excel::Template->new(
5
3632
by: John Randall | last post by:
Anybody got some sample code showing how to create a word doc and insert text plus images, such as .gif or jpg files? I'm new to Win32::OLE. Thanks in advance.
6
6480
by: poolboi | last post by:
hi all, i've got the following program that needs yr help: use Win32::OLE; # use existing instance if Excel is already running eval {$ex = Win32::OLE->GetActiveObject('Excel.Application')}; die "Excel not installed" if $@; unless (defined $ex) {
4
5459
by: ravir81 | last post by:
Hi, I am currently working on excel validation using Perl. I am new to Excel validation but not for Perl. I have a question regarding one of the validation. Could anyone please tell me how to get the number of duplicate rows based on a particular cell value of each these duplicate rows. I mean all the cell values of a row will not be duplicated but a individual columns cell value will be duplicated and I need to create a separate excel with...
0
10231
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10005
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8887
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7416
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5313
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5452
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3972
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2817
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.