How to make Win32 :: OLE work on a 64-bit MS OFFICE installation

I have two computers, I have a 32-bit version of MS Office 2013 and another MS Office 64bit. I have Perl code that uses the Win32::OLE Perl module for working with XLS spreadsheets. The code works fine on a 32-bit PC, but has a problem on a 64-bit version.

After some research, I found out about it. The problem is the following line of code:

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

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

Is there any way to set this library to 64 bit? If not, are there any other modules that would automate OLE Excel?

All my Perl script needs to do is open the XLS file and save it as a CSV. I do this with Spreadsheet::ParseExcel and Spreadsheet::XLSX in all other scripts. The problem with this particular XLS file is that it is password protected and uses non-standard password encryption. Therefore Spreadsheet::ParseExcel cannot open it. Win32::OLE has no problem opening a 32-bit file.

If necessary, a code can be provided.

Please inform.

Thanks, -Andrey

+6
source share
4 answers

I am using your Win32::OLE::Const module so that Excel constants are available in Perl.

I recently had a clean installation of Win7 x64 with Office 2016, and the script no longer worked (using the latest Win32::OLE::Const module, which is installed with the current (on 04/06/2016) ActiverPerl 64 bit installation).

After some investigation, I found that 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 file:

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

If I add a new key manually

 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 Excel typelib and worked again.

Hope this helps.

+6
source

The registry key also helps with Outlook 2013.

 /HKEY_LOCAL_MACHINE\SOFTWARE\Classes\TypeLib\{00062FFF-0000-0000-C000-000000000046}\9.5\0\win32 
+2
source

can't comment yet. therefore, sending as an answer!

  • You can use a 64-bit version of perl with an active state. Link link1

  • Link link2 can also help you, albeit about ruby.

+1
source

I don't know if this Perl module is supported by the Jet Oledb driver, maybe this download might help:

http://www.microsoft.com/en-us/download/details.aspx?id=13255

+1
source

Source: https://habr.com/ru/post/974381/


All Articles