[DUG] MS Word replacement text

Jason Coley Jason at software-solutions.co.nz
Tue Jun 16 08:00:36 NZST 2009


Hey Dave, yeah still in Palmy, still doing the same thing, the Outlook
addins, Envelopes & Labels, Office Documents and CategorieZ.

 

When I add text to a bookmark, I use the following to replace the text
using sFieldData, which is a string.

 

            oleApp.Selection.Range.Start := bmStart;

            oleApp.Selection.Text := Trim(sFieldData);

            oleApp.Selection.Range.End := bmStart;

 

And when I build the string I use #13 + #10 as a carriage return. So it
may be because of the table, have you tried doing this in document
outside of the table to see if it has the same issue. I will create some
test documents here and use my addin to add an address to a table cell
and see what happens. What version of Office 2007, what service packs
installed.

 

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 3:56 p.m.
To: Jason
Subject: Re: [DUG] MS Word replacement text

 

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/20090616/a89405d1/attachment.html 


More information about the Delphi mailing list