Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: 'emptyenum' error w/ use Win32::OLE::Const 'Microsoft Word'

by guha (Priest)
on Mar 02, 2005 at 15:57 UTC ( #435889=note: print w/ replies, xml ) Need Help??


in reply to 'emptyenum' error w/ use Win32::OLE::Const 'Microsoft Word'

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


Comment on Re: 'emptyenum' error w/ use Win32::OLE::Const 'Microsoft Word'
Select or Download Code
Re^2: 'emptyenum' error w/ use Win32::OLE::Const 'Microsoft Word'
by ff (Hermit) on Mar 02, 2005 at 19:26 UTC
    ++guha!

    Success! Thank you. No more emptyenum complaints (at least after initial testing. :-)

    I applied your suggestion to all such wd occurrences:

    # instead of: # $x->Selection->Collapse( { Direction=>wdCollapseEnd } ); # do: $x->Selection->Collapse( { Direction=>$wdc->{wdCollapseEnd} } );

    As this example also shows, I left other Word-particular terms (such as Selection, Collapse, Direction) alone.

    P.S. Yes, I wondered why mine had -1 when others had 65535, but that was a weirdness to leave for another time.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://435889]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2014-10-26 05:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (151 votes), past polls