[prev in list] [next in list] [prev in thread] [next in thread]
List: perl-win32-users
Subject: RE: Writing to word
From: <work () ngbdigital ! com>
Date: 2002-12-24 14:37:33
[Download RAW message or body]
This should get you started. The best way to learn this stuff is creating
macros and looking at the VB :(
my $Word = Win32::OLE->GetActiveObject('Word.Application') ||
Win32::OLE->new('Word.Application');
$Word->{'Visible'} = 0;
$Word->{DisplayAlerts} = 0;
# New File
my $Doc = $Word->Documents->Add();
# Document Properties
$title = $Doc->BuiltinDocumentProperties->Title->{"Value"};
$subject = $Doc->BuiltinDocumentProperties->Subject->{"Value"};
$author = $Doc->BuiltinDocumentProperties->Author->{"Value"};
# Change Font Properties for Everything
$Word->Selection->WholeStory;
$font = $Word->Selection->Font->{Name};
$size = $Word->Selection->Font->{Size};
print "$font , $size\n";
$Word->Selection->Font->{Name} = 'Courier New';
$Word->Selection->Font->{Size} = 8;
$font = $Word->Selection->Font->{Name};
$size = $Word->Selection->Font->{Size};
print "$font , $size\n";
$Word->ActiveDocument->SaveAs({FileName => $filename, FileFormat =>
wdFormatDocument});
$Doc->Close();
$Word->Quit();
Nathaniel G. Bartusiak
TTMS, Keesler AFB
-----Original Message-----
From: Suresh Govindachar [mailto:sgovindachar@yahoo.com]
Sent: Monday, December 23, 2002 1:04 PM
To: Perl-Win32-Users (E-mail)
Subject: Writing to word
Another regex question!!Hello,
The code given below (based on Chp 11 of Active Perl
Developer's Guide by Martin Brown) can read a word
document. What I want to do is create word documents
from perl with a text editor and use Word only for viewing
the final document.
So how do I create a word document from perl? Also,
where can I find a list of functions that can be used to control
all the properties (such as font, bullets, insertion of objects,
page break, table of contents, footer/header etc.) of the word
document being created?
Thanks,
--Suresh
$document = Win32::OLE->GetObject("file2read.doc");
$paragraphs = $document->Paragraphs();
$enumerate = new Win32::OLE::Enum($paragraphs);
while(defined($paragraph = $enumerate->Next()))
{
$style = $paragraph->{Style}->{NameLocal};
$text = $paragraph->{Range}->{Text};
$text =~ s/[\n\r]//g;
print "\nstyle:$style\ntext:$text\n";
}
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic