[DUG] MS Word replacement text
Dave O'Brien
dave at ICCS.CO.NZ
Mon Jun 15 15:46:18 NZST 2009
Hi Jason, long time no see... Are you still in PN?
Yes, tried all combinations of #10 & #13. The text I'm replacing is in a
table cell, so that may be something to do with it. Using Office 2007 if
that make's a difference.
I've also tried using a stringlist with multiple lines and this has the
same effect (two spaces rather than a new line).
The code I'm using is:
procedure Replace(This, That: OLEVariant) ;
begin
WA.Selection.Find.ClearFormatting ;
WA.Selection.Find.Text := This ;
WA.Selection.Find.Replacement.Text := That ;
WA.Selection.Find.Forward := True ;
WA.Selection.Find.MatchAllWordForms := False ;
WA.Selection.Find.MatchCase := False ;
WA.Selection.Find.MatchWildcards := False ;
WA.Selection.Find.MatchSoundsLike := False ;
WA.Selection.Find.MatchWholeWord := False ;
WA.Selection.Find.MatchFuzzy := False ;
WA.Selection.Find.Wrap := wdFindContinue ;
WA.Selection.Find.Format := False ;
WA.Selection.Find.Execute(Replace := wdReplaceAll) ;
end;
Where WA is:
WA := CreateOLEObject('Word.Application') ;
From: delphi-bounces at delphi.org.nz [mailto:delphi-bounces at delphi.org.nz]
On Behalf Of Jason Coley
Sent: Monday, 15 June 2009 3:26 p.m.
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] MS Word replacement text
Have you tried using just #10 (or is it just #13)
Jason
From: delphi-bounces at delphi.org.nz [mailto:delphi-bounces at delphi.org.nz]
On Behalf Of Dave O'Brien
Sent: Monday, 15 June 2009 1:54 p.m.
To: Jason
Subject: [DUG] MS Word replacement text
I'm working with Word templates, replacing markers with text. I'm having
trouble with new lines in the text, i.e. I want a new line, but the Word
document doesn't want to play. I have tried #13#10, but this just puts
two spaces in the text.
Is there another code I need to use to force a new line?
Regards,
Dave.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20090615/6c5ae943/attachment-0001.html
More information about the Delphi
mailing list