in reply to Win32::OLE running macros

try
$doc->Run("psqtemplate");
instead of
$doc1->ActiveDocument->Run("psqtemplate");

see here

Untested

Replies are listed 'Best First'.
Re^2: Win32::OLE running macros
by Anonymous Monk on May 09, 2005 at 14:37 UTC
    Thanks, been there. This just seems so straight forward.
    1. Open an instance of a MS office product
    2. Open an instance of a document using that product instance
    3. Run macro on active document using product instance
    4. SaveAs new filename.
    Obviously I am not sure why it still isn't working.
    When I make the change you suggest I get a "save" dialogue rather than a "SaveAs" one.
    I guess I just keep working on it until I find the right combination...kind of like a Rubix Cube.
      This works...in case anyone cares in the future
      #Create filenames $file =~ s/(.*)\.fin/$1/i; $file = $1; my $fileName = "$file.rtf"; my $fileName2 = "$file.doc"; my $doc = Win32::OLE->new('Word.Application', 'Quit'); $doc->Documents->Open($path); $doc->ActiveDocument->SaveAs({FileName => $fileName, FileFormat => wdF +ormatRTF}); $doc->ActiveDocument->SaveAs({FileName=> $fileName2}); $doc->Run("psqtemplate"); $doc->ActiveDocument->Save; #Close Winword $doc->Quit(); undef $doc;