Hi,
I've currently got the following code, which works fine;
However, I'm now trying to add a header/footer page to every document (to stop theives, or at least discourage them).
Does anyone know how to do this with Win32::OLE in Word?
TIA
Andy
I've currently got the following code, which works fine;
Code:
my $doc;
$doc = $Word->Documents->Open($fullpath_doc) || die Win32::OLE->LastError;
# if (ref $doc->BuiltInDocumentProperties("Title") eq "HASH") {
$doc->BuiltInDocumentProperties("Title")->{Value} = $title;
$doc->BuiltInDocumentProperties("Subject")->{Value} = $title;
$doc->BuiltInDocumentProperties("Author")->{Value} = $title;
$doc->BuiltInDocumentProperties("Manager")->{Value} = $title;
$doc->BuiltInDocumentProperties("Company")->{Value} = $title;
$doc->BuiltInDocumentProperties("Comments")->{Value} = $comments;
$doc->BuiltInDocumentProperties("Category")->{Value} = $title;
$doc->BuiltInDocumentProperties("Keywords")->{Value} = $title;
$doc->BuiltInDocumentProperties("Hyperlink Base")->{Value} = "[URL unfurl="true"]http://www.$destsite";[/URL]
$doc->CustomDocumentProperties->Add({
Name => "Downloaded From",
LinkToContent => 0,
Type => 4,
Value => "[URL unfurl="true"]http://www.$destsite/"[/URL]
});
$doc->CustomDocumentProperties->Add({
Name => "Owner",
LinkToContent => 0,
Type => 4,
Value => "$destsite/"
});
$doc->CustomDocumentProperties->Add({
Name => "Copyright",
LinkToContent => 0,
Type => 4,
Value => "$destsite"
});
$doc->CustomDocumentProperties->Add({
Name => "Can Redistribute",
LinkToContent => 0,
Type => 4,
Value => "No, do not redistribute/"
});
$doc->Range->InsertBefore("$insert_before_one\n\n");
$doc->Range->InsertBefore("$insert_before_two\n\n");
my $fontTitleParagraph = $doc->Paragraphs->Count - $doc->Paragraphs->Count + 2;
my $fontExampleParagraph = $doc->Paragraphs->Count - $doc->Paragraphs->Count + 3;
my $range = $doc->Paragraphs($fontTitleParagraph)->Range;
$range->Font->{Name} = "Verdana";
$range->Font->{Size} = 10;
$range->Font->{Bold} = -1;
$range = $doc->Paragraphs($fontExampleParagraph)->Range;
$doc->Hyperlinks->Add();
$doc->Hyperlinks->Add( {Anchor => $range, Address => "[URL unfurl="true"]http://www.$destsite",[/URL] SubAddress => ""});
$range->Font->{Name} = "Verdana";
$range->Font->{Size} = 8;
my $formatStart = $doc->Paragraphs($fontTitleParagraph)->Range->Start;
my $formatEnd = $doc->Paragraphs($fontExampleParagraph)->Range->End;
$doc->Range->InsertAfter("\n\n$insert_after_one\n\n");
$doc->Range->InsertAfter("$insert_after_two\n\n");
$fontTitleParagraph = $doc->Paragraphs->Count - 3;
$fontExampleParagraph = $doc->Paragraphs->Count - 2;
$range = $doc->Paragraphs($fontTitleParagraph)->Range;
$range->Font->{Name} = "Verdana";
$range->Font->{Size} = 10;
$range->Font->{Bold} = -1;
$range = $doc->Paragraphs($fontExampleParagraph)->Range;
$doc->Hyperlinks->Add();
$doc->Hyperlinks->Add( {Anchor => $range, Address => "[URL unfurl="true"]http://$destsite",[/URL] SubAddress => ""});
$range->Font->{Name} = "Verdana";
$range->Font->{Size} = 8;
my $formatStart = $doc->Paragraphs($fontTitleParagraph)->Range->Start;
my $formatEnd = $doc->Paragraphs($fontExampleParagraph)->Range->End;
$doc->Save();
$doc->Close();
However, I'm now trying to add a header/footer page to every document (to stop theives, or at least discourage them).
Does anyone know how to do this with Win32::OLE in Word?
TIA
Andy