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

11,225

Solution 1

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.

Solution 2

Registry key also helps with Outlook 2013.

/HKEY_LOCAL_MACHINE\SOFTWARE\Classes\TypeLib\{00062FFF-0000-0000-C000-000000000046}\9.5\0\win32
Share:
11,225
Andrey
Author by

Andrey

Updated on June 04, 2022

Comments

  • Andrey
    Andrey almost 2 years

    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

  • Mike Caron
    Mike Caron over 7 years
    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!
  • yossiz74
    yossiz74 over 3 years
    Works like magic! win10 with Office 64bit. Thank you!
  • Alfred Manoj
    Alfred Manoj over 2 years
    This worked for me! searched a lot and this one is perfect!! Thanks a lot for saving my day