There is another way to get to the Word-constants, which in my experience is more stable, when there are many constants, as there indeed are in Word.
I would like to encourage you to try this instead to see if it helps:
use Win32::Shortcut;
use Win32::OLE qw(in with);
use Win32::OLE::Const; ##=>Changed
my $wdc = Win32::OLE::Const->Load("Microsoft Word"); ##=>Added
my $x = Win32::OLE->GetActiveObject('Word.Application');
# snip
$x->Selection->Delete( {
Unit=> $wdc->{wdCharacter}, ##=>Changed
Count=>1
} );
Searching through some old email conversations with jand, the author/maintainer of Win32::OLE, from 2002 I found this.
>>Another feature is that standard way to handle wdCONSTANTS
>>
>>use Win32::OLE::Const 'Microsoft Word';
>>
>>does not work anymore, I resorted to
>>
>>use Win32::OLE::Const;
>>....
>> $obj->{_WD} = Win32::OLE::Const->Load("Microsoft Word"); # 9.0 Obje
+ct
>>Library");
>
> Hmm, do you get any errors or anything?
>
"Constant subroutine emptyenum redefined at
C:/DEV/Perl/site/lib/Win32/OLE/Const.
pm line 65535." times 13 (Bad luck ??)
Nothing new under the sun, it seems. But the indicated way works.
Notice that your erroneous linenumber is -1 whereas mine is 65535, 16 bit integers or what?
HTH
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.