This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

v1.7.9 env--MS Word COM ifc reports spurious error when invoked from perl (ActiveState works fine)


Cygwin version: CYGWIN_NT-6.1-WOW64 I5 1.7.9(0.237/5/3) 2011-03-29
10:10 i686 Cygwin

Host: ?MS Windows 7, SP1, 64Bit OS

Cygwin Perl Version: v5.10.1 (*) built for i686-cygwin-thread-multi-64int

MS Word Version: ?Office 2010 or Office 2007.

==================================================

A simple Win32 COM script (included below) dies when invoked like so:

$ perl broken_with_cygwin.pl
Can't call method "PageSetup" on an undefined value at
broken_with_cygwin.pl line 23.
$ cat broken_with_cygwin.pl
#!/bin/perl

? ?use Win32::OLE;
? ?use Win32;

? ?my ($Word, $tmp_out_file);

? ?$tmp_out_file = Win32::GetCwd() . "__some_junk_temp_file__.txt";
? ?open(TMP_OUT_FILE, '>', $tmp_out_file) or
? ? ? ?die "$0: error opening temporary output file \"$tmp_out_file\": $!";
? ?print TMP_OUT_FILE "one line of text\n";
? ?close TMP_OUT_FILE;

? ?if (! ($Word = Win32::OLE->new('Word.Application')))
? ?{
? ? ? ?die "failed to start MS Word, aborting\n";
? ?}
? ?$Word->{Visible} = 1; ? ? # make word visible
? ?$Word->Activate; ? ? ? ? ?# and activate word
? ?$Word->Documents->Add; ? ?# create a new, empty document
? ?$Word->Selection->InsertFile($tmp_out_file);
? ?$Word->ActiveDocument->PageSetup->{LeftMargin} ?= 36; ? # 0.5 in
? ?$Word->ActiveDocument->PageSetup->{RightMargin} = 36; ? # 0.5 in

? ?# mark newly created document as "saved" (so it can be clicked away
? ?# without a prompt to save the "file").
? ?$Word->ActiveDocument->{Saved} = 1;
? ?unlink $tmp_out_file;

======================
If I run this script in a Windows XP environment (using the same
version of perl and cygwin), no errors are reported.

If I run this same script in a cmd.exe shell, no errors are reported.

If I run this same script via the ActiveState Perl interpreter, no
errors are reported.

I've attached the script and the output of "cygcheck -s" .

- Clark Morgan

Attachment: cygcheck_output.txt
Description: Text document

Attachment: broken_with_cygwin.pl
Description: Binary data

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]