8

I have two PCs, one has MS Office 2013 32bit installed and another MS Office 64bit installed. I have Perl code that is using Win32::OLE Perl module to manipulate XLS spreadsheets. The code is working perfectly fine on 32bit PC, but has a problem on 64bit one.

After doing some research here is what I found out. The problem is the following line of code:

use Win32::OLE::Const 'Microsoft Excel .* Object Library';

I looked inside Win32::OLE::Const module and it seems that the module is looking for that library in the registry. When I printed out all entries from the registry from both 32 and 64 bit I found out that this library is available on 32bit and not available on 64bit.

Is there a way to install that library on 64 bit? If not, are there any other modules that would allow OLE automation of Excel?

All my Perl script needs to do is to open XLS file and save it as CSV. I am doing it with Spreadsheet::ParseExcel and Spreadsheet::XLSX in all other scripts. The problem with this particular XLS file is that it is password protected and using non-standard password encryption. So Spreadsheet::ParseExcel is not able to open it. Win32::OLE has no issues opening the file on 32bit.

Code can be provided if needed.

Please advise.

Thank you, -Andrey

Andrey
  • 1,808
  • 1
  • 16
  • 28
  • 1
    Are you trying to link to the library on the 64 bit machine from 32 bit or 64 bit perl? – Oesor Aug 26 '14 at 20:52
  • I am not trying to link. I am trying to figure out why Microsoft Excel .* Object Library is available on 32bit and not available on 64bit and is there a way to make it available. – Andrey Aug 27 '14 at 13:10
  • That's what I mean by linking to the library. Are you trying to do it from 32 bit perl or 64 bit perl on the 64 bit machine? – Oesor Aug 27 '14 at 14:50
  • This is perl 5, version 16, subversion 3 (v5.16.3) built for MSWin32-x64-multi-thread – Andrey Aug 27 '14 at 14:58
  • I have the same problem using both Excel and Outlook. I was using Perl 5.10. I just upgraded to Perl 5.18 and the problem is still there. – Hugues Sep 20 '14 at 22:19
  • It has nothing to do with Perl version. I have read through the module itself. It refers to the library that only exists on 32bit installation. I still cannot find how to make it work on 64 bit. – Andrey Sep 22 '14 at 13:15
  • Did you try installing the Microsoft Access Database Engine? The official site offering the drivers of MS Office 2010 seems to support Excel as well. Link: http://www.microsoft.com/en-in/download/details.aspx?id=13255 – Gurusharan S Sep 27 '14 at 04:22
  • Is there a reason you need 64bit Office. You could install 32bit office on 64bit windows. Unless you are using huge spreadsheets that require a large amount of memory 32Bit office should suffice. Microsoft pretty much suggests installing 32bit office if you want better compatibility. See this link: http://office.microsoft.com/en-us/support/choose-the-32-bit-or-64-bit-version-of-office-HA102840825.aspx – Michael Petch Sep 29 '14 at 05:46
  • @Michael Petch: That is the current environment of the company I am currently working: some PCs have 32bit some 64bit. Therefore my script has to be working on both. – Andrey Sep 29 '14 at 16:00
  • Using ActivePerl (perl 5, version 16, subversion 3 (v5.16.3) built for MSWin32-x64-multi-thread) on 64 Bit Win8.1 using Office 2013 Professional Plus and specifically Microsoft Excel 2013 (15.0.4649.1000) MSO (15.0.4649.1000) 64-Bit (Shown in Excel's About dialog) - I was able to use the sample code with SpreadSheet:ExcelParser (Verison 0.65)to read an `.xls` file and dump out the contents properly and SpreadSheet:XLSX (version 0.13) using Win32::OLE (Version 0.1711) to dump the contents of an `.XLSX` file and it worked as expected too. – Michael Petch Sep 29 '14 at 19:13
  • I have the same problem with the latest 64 bit Perl version. Any updates? – Demiurg Apr 11 '15 at 11:38

2 Answers2

16

I use your Win32::OLE::Const module to have the Excel constants available in Perl.

Recently, I had a clean Win7 x64 install with Office 2016 and the script was not working anymore (using the latest version Win32::OLE::Const module which is installed with the current (on 06/04/2016) ActiverPerl 64 bit installation).

After some investigation, I have found out that the Win32::OLE::Const did not see the Excel automation object although it was well registered and available in the registration database.

In the registration database the following key contains the path to the Excel executable:

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\TypeLib\{00020813-0000-0000-C000-000000000046}\1.9\0\Win64

If I add manually a new key

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\TypeLib\{00020813-0000-0000-C000-000000000046}\1.9\0\Win32 

with the same path as for the Win64 key then the Perl script found the Excel typelib and worked again.

Hope this helps.

Wtower
  • 18,848
  • 11
  • 103
  • 80
bl89
  • 176
  • 2
  • 3
2

Registry key also helps with Outlook 2013.

/HKEY_LOCAL_MACHINE\SOFTWARE\Classes\TypeLib\{00062FFF-0000-0000-C000-000000000046}\9.5\0\win32
Unheilig
  • 16,196
  • 193
  • 68
  • 98