Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Win32::OLE not opening a window for me

by ww (Bishop)
on Mar 23, 2012 at 13:27 UTC ( #961208=note: print w/ replies, xml ) Need Help??


in reply to Win32::OLE not opening a window for me

"the message, "Main::$doc only used once" which may be something."

Yes, it indeed is "something."

It is telling you that you have used the variable $doc only once (in scope) in your script.

Perhaps you've drawn an incorrect conclusion about visibility (which I infer from your title): $doc is visible to perl in (some part of) the script; if you want "eyeballs on" the contents of $doc, you'll need to send it to your console (screen), and, if you want an accurate display, decode from Word's character set to the once used by your console. (see davies's Re: Win32::OLE not opening a window for me above)....

( ... and, of course, that presumes that you've provided an accurate path and filename in $document_path. More detail on the script may be needed to ascertain that, if there's another problem.)

Update: ... 'oops!', says /me. I now think I misunderstood/misread part of your problem. The message you quote is, indeed, telling you what I said in the first two para after the quote, but John Davies' understanding of what you were talking about re "visible" seems likely to be far closer to be an answer to your visibility issue than that in the portion marked by strikethrus above.

Update 2: PS: if you're using strict (highly recommended because it can help find one's errors), then you should have received another message... something to the general effect that " ... $doc requires requires explicit package name at line nnn." The more we know about things like error messages and warnings, the better the help we provide (as long as we don't misread the problem :-( ).


Comment on Re: Win32::OLE not opening a window for me
Select or Download Code
Re^2: Win32::OLE not opening a window for me
by Anonymous Monk on Mar 23, 2012 at 14:03 UTC

    Thanks for taking the time - yes, I did want to get it to actually open as a Word document, though for my own satisfaction before trying to do something useful with it so will be aware of converting the character set which will still apply, I think. But the other reply did work for viewing.

    The console printed a message from Word telling me when the document didn't exist which was useful as I hadn't put in any error checking.

    Cheers

    Moray

      In general, error checking on open -- open ($FH "<", $filename) or die "Can't open $filename, $!";Note1 for one possible example -- and using strict and warnings are almost certain to be very helpful when you're experimenting in the way you describe..

      I don't use Win32::OLE in the manner you are (and in fact, rarely in any fashion), so I have to ask: Are you sure the message to the console came from Word? I suspect it more likely came from Win32::OLE (or, less likely) from Perl itself).

      Update: Note1 In a msg, davies points out (++) that the open illustrated in para 1 is a generalized form may be confusing in context. I agree, and should have phrased it to make clear that it is probably not applicable to file opens performed by/with Win32::OLE or the like.

        Hi, I'm not sure where the message came from, but there was a code returned which I googled to find it was a Windows code for missing a file. Then I noticed that there was some helpfully written words that said the same thing - I'm guessing that Win32::OLE

        If I want to improve, I need to start using strict, that's for sure.

        MorayJ

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2014-12-20 06:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (95 votes), past polls