How to make Win32::OLE work on 64bit MS OFFICE installation
Asked Answered
T

2

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

Tubby answered 26/8, 2014 at 15:45 Comment(11)
Are you trying to link to the library on the 64 bit machine from 32 bit or 64 bit perl?Wende
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.Tubby
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?Wende
This is perl 5, version 16, subversion 3 (v5.16.3) built for MSWin32-x64-multi-threadTubby
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.Harewood
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.Tubby
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: microsoft.com/en-in/download/details.aspx?id=13255Wynne
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: office.microsoft.com/en-us/support/…Exhortative
@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.Tubby
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.Exhortative
I have the same problem with the latest 64 bit Perl version. Any updates?Varden
S
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.

Saturninasaturnine answered 7/4, 2016 at 7:55 Comment(3)
This helped me. I was using Office 64, Active Perl x64 and it still couldn't find the type lib. I then applied the registry fix and voila! It worked!Calamine
Works like magic! win10 with Office 64bit. Thank you!Sumrall
This worked for me! searched a lot and this one is perfect!! Thanks a lot for saving my daySwain
B
2

Registry key also helps with Outlook 2013.

/HKEY_LOCAL_MACHINE\SOFTWARE\Classes\TypeLib\{00062FFF-0000-0000-C000-000000000046}\9.5\0\win32
Babe answered 17/4, 2017 at 22:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.