BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Word and adding borders programmatically

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation
View previous topic :: View next topic  
Author Message
Richard
Guest





PostPosted: Sat Apr 14, 2007 7:57 am    Post subject: Word and adding borders programmatically Reply with quote



Hi,
I am using D6 with sp2, XP and SP2 and Word 2002.
I have done the Word macro bit and have converted the VB macro code into
pascal to set a border round each page in a Word document. I want the border
to be anchored to the edge of the page not the text, which is the
DistanceFrom property. There are two options, wdBorderDistanceFromText and
wdBorderDistanceFromPageEdge, but regardless of which I choose it always
anchors the borders to the text. In standalone Word it behaves properly when
I make the appropriate selection.

This is the code:

worddocument1.Paragraphs.Format.Borders.item(wdBorderLeft).LineStyle :=
wdLineStyleSingle;
worddocument1.Paragraphs.Format.Borders.Item(wdBorderLeft).LineWidth :=
wdLineWidth050pt;
worddocument1.Paragraphs.Format.Borders.Item(wdBorderLeft).Color :=
wdColorAutomatic;
[repeats for the other 3 edges]

worddocument1.Paragraphs.Format.Borders.DistanceFrom :=
wdBorderDistanceFromPageEdge; // problem line
worddocument1.Paragraphs.Format.Borders.AlwaysInFront := True;// the rest
of this seems to work ok
worddocument1.Paragraphs.Format.Borders.SurroundHeader := True;
worddocument1.Paragraphs.Format.Borders.SurroundFooter := True;
worddocument1.Paragraphs.Format.Borders.JoinBorders := False;
worddocument1.Paragraphs.Format.Borders.DistanceFromTop := 24;
worddocument1.Paragraphs.Format.Borders.DistanceFromLeft := 24;
worddocument1.Paragraphs.Format.Borders.DistanceFromBottom := 24;
worddocument1.Paragraphs.Format.Borders.DistanceFromRight := 24;
worddocument1.Paragraphs.Format.Borders.Shadow := true;
worddocument1.Paragraphs.Format.Borders.EnableFirstPageInSection := True;
worddocument1.Paragraphs.Format.Borders.EnableOtherPagesInSection := True;
worddocument1.Paragraphs.Format.Borders.ApplyPageBordersToAllSections;

Has anyone else come across this one, or got a workround?
Any help greatly appreciated
Richard
Back to top
Oliver Townshend
Guest





PostPosted: Wed Apr 18, 2007 8:12 am    Post subject: Re: Word and adding borders programmatically Reply with quote



Quote:
Has anyone else come across this one, or got a workround?
Any help greatly appreciated

Sometimes when a feature doesn't work in Delphi but does work in Word it
pays to use OleVariants, which are a bit slower.

Oliver Townshend
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.