Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Word Automation through Win32::OLE
Long time lurker, first time poster...please be gentle.

I am attempting to move through a directory, pull out only files of a
.fin extension (which is Word document format), save each one as .rtf
(Rich Text Format).  I'd also like to be able to run some predefined
macros on the files, but I thought just being able to save was a good
place to start.

Currently I get an error stating 'Can't call method "SaveAs" on an
undefined value'.
If someone could point me to some clearer text on Win32::OLE  than the
stuff that ASPN, CPAN and Oreilly's Win32 or Nutshell book I'd greatly
appreciate it.  If you could tell me what stupid thing I am missing this
time that would be great too.

Here's the code:
#usr/bin/perl
use Win32::OLE;
use Win32::OLE::Const 'Microsoft Word';
$articleDirName = "c:\\work\\test\\psq\\test\\";
unless (opendir(DIR, $articleDirName)) {
warn "Can't open $articleDirName\n";
closedir(DIR);
exit(1);
}
foreach (readdir(DIR))
{
next if $_ eq '.' || $_ eq '..';
$path = "$articleDirName$_";
if (-f $path){
if ($path =~ /\.fin/i){
$doc = Win32::OLE->GetObject($path);
$fileName = $path . ".rtf";
print "$fileName\n";
$doc->ActiveDocument->SaveAs({FileName => $fileName,
FileFormat => wdFormatRTF})
}
undef $doc;
undef $path;
undef $fileName;
}
}




Report this thread to moderator Post Follow-up to this message
Old Post
Mark Shellenberger
12-23-04 02:00 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Beginners archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 08:09 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.