in reply to Another Win32::OLE question

What does the code around it look like when it is in the fail environment?

Is the word object declared in the same scope? Did you change working directories before trying to open the $template such that you are having a failure opening that file?

Set $Win32::OLE::Warn = 3; # Fail on errors in this conext:

use strict; use Win32::OLE ; use Win32::OLE::Const 'Microsoft Word'; $Win32::OLE::Warn = 3; # Fail on errors my $Word = Win32::OLE->GetActiveObject('Word.Application') || Win32::OLE->new('Word.Application', 'Quit');

and then print Win32::OLE->LastError(); before you exit to get some error checking, in case you didn't have a fatal error.

C-.

Replies are listed 'Best First'.
Re: Re: Another Win32::OLE question
by Gerard (Pilgrim) on Oct 21, 2001 at 03:51 UTC
    I am positive that I had not changed the directory at all. I checked this before posting my question. I could not think of anything, but I read through my whole script anyway and could not find anywhere. After reading your reply I decided to change to the directory that it should be just in case. It worked! Which is good, but kind of annoying that I have wasted my own and everyones time. Now I just need to see why it is changing directories without my telling it to... Cheers all for the advice.
      I've found while working with ::OLE it's best to explicitly detail your file paths and file names, especially if this is a remote application on a webserver. The Webservers working directory ISN'T necessarily the directory of the application, believe it or not.

      Be that as it may, I'm glad I could help.

      C-.

        Actually it will be for Windows systems, I will not be running it from a webserver. I was a little hesitant to change the directory to the correct directory because if someone does not do standard installation of my program it will not work. (I will not know what the directory is). Of course with a little bit of thought I got around this by using Cwd at the beginning of my script and then changing to that directory later on. Still there is much to learn, but it is enjoyable. Cheers once again.