I have written a little app, where I would like to dynamically create a 
directory of resource providers, using Perl OLE and Word10.  I would 
like the directory to contain:
1.  A full page color graphic
2.  Table of Contents
3.  Contents:  each resource provider listed on a page, separated by a 
page break.

Each of these aspects I have successfully performed, individually.  
Where I am having my problems is in setting ranges for different 
formatting.  For instance, the first page, the cover art should bleed to 
the edges.  Then, a page break, then the Table of Contents, with 1" 
borders all the way around, page break, followed by the resource 
provider listings, each separated by a page break and formatted w/ 1" 
borders.

I begin by using 'PageSetup' to set all margins to 0" (for full bleed).  
Then, I add the InlineShape to the first page.  Everything works to that 
point.  Now, I would like to reset the page borders to 1" all around and 
begin adding the Table of Contents and other text.  Unfortunately, every 
time I adjust the PageSetup parameters, ALL the margins are reset, 
negating the 0" margins I had established for the cover art.

I have read every archived email re: OLE and Word, combed my Office 
Developer's Guide book (VBA), searched Google for anything available, 
but the examples I have found do not address multiple page margins 
within a single document.

Below is the code I have written so far.  Is there anyone out there who 
has fond experiences with OLE automation of Word who can help me 
through this?  Thanks in advance.

use Win32::OLE;
use Win32::OLE::Const 'Microsoft Word';

my($outputFile) = "c:/check_this_file.doc";

my($WordApp) = Win32::OLE -> new('Word.Application', 'Quit');
$WordApp-> {Visible} = 1;
$WordApp -> Documents -> Add;

$PageSetup=$WordApp->ActiveDocument->PageSetup;
$PageSetup -> {LeftMargin}  = $WordApp -> InchesToPoints(0);
$PageSetup -> {RightMargin} = $WordApp -> InchesToPoints(0);
$PageSetup -> {TopMargin}   = $WordApp -> InchesToPoints(0);
$PageSetup -> {BottomMargin}= $WordApp -> InchesToPoints(0);

$coverart="c:/find-out_directory_cover.jpg";
$InsertCover=$WordApp->Selection->InlineShapes-
>AddPicture({FileName=>$coverart});
$InsertCover=$WordApp->Selection-
>InsertBreak({Type=>wdPageBreak});

$PageSetup2=$WordApp->ActiveDocument->PageSetup;
$PageSetup2 -> {LeftMargin}  = $WordApp -> InchesToPoints(0.75);
$PageSetup2 -> {RightMargin} = $WordApp -> InchesToPoints(0.75);
$PageSetup2 -> {TopMargin}   = $WordApp -> InchesToPoints(0.75);
$PageSetup2 -> {BottomMargin}= $WordApp -> InchesToPoints(0.75);

$WordApp->Selection->Font->{Size} = '12';
$WordApp->Selection->TypeText( "Let's try some text in here to see 
what happens." );
$WordApp->ActiveDocument->SaveAs({FileName=>$outputFile,
                                  FileFormat=>wdFormatDocument});
$WordApp->ActiveDocument->Close();
$WordApp->Quit();

Brad Smith

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to