in reply to Re^2: How to use win32::OLE with multiple versions of Microsoft Office?
in thread How to use win32::OLE with multiple versions of Microsoft Office?

Understood. I had used double quotes in the past, but got tired of escaping the period. I tried your version, and I tried this as well:
use Win32::OLE::Const "Microsoft Office \.* Object Library"; # mso co +nstants
but no joy. No complaint from Win32::OLE, but no msoFalse defined...

I forget how I figured out that I needed to put in the exact version number (11.0, 12.0, or 14.0), but that is the only way I have been able to get this to work. I tried to figure out a way to select the right version in a BEGIN-END block, but I lack the perlMonkishness to get that going.

I can live with one of two solutions (either modify the script for the specific host version of Office -- yuck); or the way it is now (looks ugly as sin, but seems to work; and if multiple versions of office exist, I'll take my chances.

  • Comment on Re^3: How to use win32::OLE with multiple versions of Microsoft Office?
  • Download Code

Replies are listed 'Best First'.
Re^4: How to use win32::OLE with multiple versions of Microsoft Office?
by dasgar (Priest) on Aug 04, 2011 at 19:33 UTC

    I don't want to doubt what you're saying, but I am surprised that you're having issues. That line of code has worked for me on multiple systems and across multiple versions of Office (97,2003,2007,2010) on different Windows versions (XP, Vista, Win7, Win2003, Win2008) and different versions of Perl without any problems.

    In fact, I just ran the code below on a Win7 box with ActiveState Perl 5.12.1 and Office 2010 installed. It ran without any errors or complaints.

    use strict; use warnings; use Win32::OLE::Const "Microsoft Office .* Object Library";

    I believe that I'm out of ideas/suggestions at this point. If I can think of anything, I'll come back and post it.

      Hi Dasgar, thanks for your continuing efforts to bring clarity and monkish wisdom. I wrote this snippet:
      # print out constants loaded for Microsoft Office use strict; use warnings; use Win32::OLE::Const "Microsoft Office .* Object Library"; my $names = Win32::OLE::Const->Load("Microsoft Office .* Object Librar +y"); printf "Office type library contains %d constants:\n", scalar keys %$n +ames; foreach my $Key (sort keys %$names) { print "$Key = $names->{$Key}\n"; }
      Perl64 5.14.1 responds with:
      C:\winbat>perl -w msoconstants.pl Office type library contains 221 constants: KeepLocal = 0 LogMessages = 0 Replicable = 0 ReplicableBool = 0 V1xNullBehavior = 0 dbAppendOnly = 8 dbAttachExclusive = 65536 dbAttachSavePWD = 131072 dbAttachedODBC = 536870912 dbAttachedTable = 1073741824 dbAttachment = 101
      (more than 200 lines of similar output suppressed). Apparently there are multiple typelibs in the registry, and only by coding 14.0 do I get the mso constants.

      As far as I know, there was only one installtaion of Office 2010 on this machine, but those db constants suggest that Access (a part of Office Pro) might be involved?

        Hi guys,

        can I use Win32::OLE without installing MS Office??

        Kindly suggest me something for this.