Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I have several perl programs which have been running successfully for some time on WinXP using WIN32::OLE, using the interface for both Excel and Word. These programs run on both of our home machines. Recently I started having problems creating the object for Word but only on one of the machines, not the other. The following snippet has worked correctly in the past and still works on the other machine but for some reason it is not returning the object reference.
$word = Win32::OLE->GetActiveObject('Word.Application') || Win32::OLE->new('Word.Application'); $mydoc = $word->Documents->Open($xfile);
The Open fails because $word is not defined. Similar code for Excel still works fine.

The boilerplate at the beginning of the program contains:

use Win32; use Win32::OLE; use Win32::OLE "with"; use Win32::OLE::Const 'Microsoft Excel'; use Win32::OLE::Const 'Microsoft Word'; use Win32::OLE::Const 'Visual Basic For Applications'; use Win32::OLE::Variant;

It appears that something has changed on this machine but I don't know what to look for. I recently had some problems with my virus checking program for which the "fix" caused some registry problems for I.E. but AFAIK fixing those did not affect anything else.

I have also tried using CreateObject and GetObject but they do not return an object reference either. Is there something in the OLE stuff that gets registered that may have gotten unregistered? Any ideas of what I should look for?

Addendum: When I set Win32::OLE::Warn=2 I get the error message that I have an "Invalid Class String".


In reply to Win32::OLE create object failing by esr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2024-04-19 09:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found