On approximately 5/8/2009 12:07 PM, came the following characters from 
the keyboard of Jan Dubois:
> On Fri, 08 May 2009, Glenn Linderman wrote:
>> So I open a workbook with macros, and then another workbook with data,
>> and run A_macro... as follows...
>>
>>
>>        require Win32::OLE;
>>        require Win32::OLE::Const;
>>        Win32::OLE::Const->Load('Microsoft Excel');
>>        $Win32::OLE::Warn = 3;
>>        $Win32::OLE::Warn = 3;
>>
>>        my $Excel = Win32::OLE->new('Excel.Application', 'Quit');
>>
>>        my $gl = $Excel->Workbooks->Open(
>>      $ENV{'APPDATA'} . "\\Microsoft\\Excel\\XLSTART\\gl.xls");
>>        my $Book = $Excel->Workbooks->Open("SomeData.xls");
>>        $Excel->Run("gl.xls!A_macro");
>>        $Book->Close( 0 );
>>        $gl->Close( 0 );
>>        $Excel->Close;
>>
>> I get an error on the last line:
>>
>> Win32::OLE(0.1707) error 0x80020011: "Does not support a collection"
>>      in METHOD/PROPERTYGET "" at d:\my\perl\src\roster_data.pl line 3352
> 
> Your sample program above doesn't have over 3000 lines, so the error
> message and the code don't seem to be related.


I didn't figure everyone would appreciate the 8863 lines... but the part 
that uses OLE is fully reproduced above.  My reference to the last line, 
$Excel->Close; is line 3352.  Unless Perl is reporting the wrong line 
number, but I have no indication that is the case.


>> Any clues as to what this message means, in this context?  And how I can
>> cure it?
> 
> I have a suspicion that your program is not running under "use strict".
> Could you enable "use strict" and see if the error message changes?


It is running under use strict; but that is way up top from the fragment 
I pasted.


> Without "use strict" Win32::OLE will retry some failed method calls
> as indexing into unnamed collections instead.  That code exists
> solely for backwards compatibility and is generally not desirable.


Ah, so maybe because I did a "require Win32::OLE" instead of "use 
Win32::OLE" the strictness doesn't carry over?  Since most runs of the 
program don't need this code, I was trying to avoid the compile time use...


-- 
Glenn -- http://nevcal.com/
===========================
A protocol is complete when there is nothing left to remove.
-- Stuart Cheshire, Apple Computer, regarding Zero Configuration Networking
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to