I'm trying to open a .docx
file using the following code:
require Win32::OLE;
my $docfile = "C:/Users/me/Documents/file.docx";
my $Word = Win32::OLE->GetActiveObject('Word.Application');
unless ($Word) { $Word = Win32::OLE->new('Word.Application', sub {$_[0]->Quit;}) or die "oops\n"; }
$Word->{visible} = 1;
my $File = $Word->Documents->Open($docfile);
$File->PrintOut();
$File->Close();
$Word->Quit();
But i get the following error:
OLE exception from "Microsoft Word":
Sorry, we couldn’t find your file. Is it possible it was moved, renamed or deleted? (C://Users/me/Documents/...)
How can i fix this? Why does it add // to my path? (needless to say, the file does exist in the system and that is the correct path).
Thanks!