<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2800.1458" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV dir=ltr align=left><SPAN class=016193005-01102004><FONT face=Arial
color=#0000ff size=2>Thanks for your help Allen and Brian - StoryRanges did
the trick.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=016193005-01102004><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=016193005-01102004><FONT face=Arial
color=#0000ff size=2>Regards,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=016193005-01102004><FONT face=Arial
color=#0000ff size=2>Paul.</FONT></SPAN></DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> delphi-bounces@ns3.123.co.nz
[mailto:delphi-bounces@ns3.123.co.nz] <B>On Behalf Of </B>Brian
Wrigley<BR><B>Sent:</B> Friday,October,01,2004 5:11 p.m.<BR><B>To:</B> NZ
Borland Developers Group - Delphi List<BR><B>Subject:</B> Re: [DUG] Word
Automation<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV><FONT face=Arial size=2>Yes, the Content object is just the main text. You
can use the Storyranges collection to access other parts of the document (eg
header, footer etc). Example (from the Word Visual Basic
reference):</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT size=2>Use the NextStoryRange property to loop through all stories in
a document. The following example searches each story in the active document for
the text "Microsoft Word." When the text is found, it's formatted as
italic.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face="Courier New" size=2>For Each myStoryRange In
ActiveDocument.StoryRanges<BR> myStoryRange.Find.Execute
FindText:="Microsoft Word", Forward:=True<BR> While
myStoryRange.Find.Found<BR>
myStoryRange.Italic = True<BR>
myStoryRange.Find.Execute FindText:="Microsoft Word",
Forward:=True<BR> Wend<BR> While Not
(myStoryRange.NextStoryRange Is
Nothing)<BR> Set myStoryRange =
myStoryRange.NextStoryRange<BR>
myStoryRange.Find.Execute FindText:="Microsoft Word",
Forward:=True<BR> While
myStoryRange.Find.Found</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New"
size=2>
myStoryRange.Italic =
True<BR>
myStoryRange.Find.Execute FindText:="Microsoft Word",
Forward:=True<BR>
Wend<BR> Wend<BR>Next myStoryRange</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>(End of example)</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I'm not sure whether the Word VB Help is installed
by default. If you don't have it, often you can figure out what you need to do
by going through the actions you want to perform in the macro recorder and then
studying the code it writes.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Hope this is enough to get you headed in the right
direction. I haven't tried it out for myself, but it looks like it's addressing
the right area for what you're trying to do.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Regards,</FONT></DIV>
<DIV><FONT face=Arial size=2>Brian</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=paul.marshall@agresearch.co.nz
href="mailto:paul.marshall@agresearch.co.nz">Marshall, Paul</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=delphi@ns3.123.co.nz
href="mailto:delphi@ns3.123.co.nz">NZ Borland Developers Group - Delphi
List</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Friday, October 01, 2004 4:08
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [DUG] Word Automation</DIV>
<DIV><BR></DIV>
<DIV><SPAN class=160495903-01102004><FONT face=Arial color=#0000ff size=2>I'm
using Word automation to create a report. </FONT></SPAN></DIV>
<DIV><SPAN class=160495903-01102004><FONT face=Arial color=#0000ff
size=2>Opening a template file, and using Find/Replace to substitute various
tokens with real data.</FONT></SPAN></DIV>
<DIV><SPAN class=160495903-01102004><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=160495903-01102004><FONT face=Arial color=#0000ff size=2>This
sort of thing seems to work:</FONT></SPAN></DIV>
<DIV><SPAN class=160495903-01102004><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=160495903-01102004><FONT face=Arial color=#0000ff
size=2>WordDoc1.Content.Find.Execute(vSearchText, EmptyParam, EmptyParam,
EmptyParam, EmptyParam,
EmptyParam,<BR>
EmptyParam, vWrap, EmptyParam, vReplaceText, vAll,
EmptyParam,<BR>
EmptyParam, EmptyParam, EmptyParam);</FONT></SPAN></DIV>
<DIV><SPAN class=160495903-01102004><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=160495903-01102004><FONT face=Arial color=#0000ff size=2>But
it only finds and replaces in the body of the document, not in the header or
footer sections.</FONT></SPAN></DIV>
<DIV><SPAN class=160495903-01102004><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=160495903-01102004><FONT face=Arial color=#0000ff size=2>Can
anyone tell me what I need to do?</FONT></SPAN></DIV>
<DIV><SPAN class=160495903-01102004><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=160495903-01102004><FONT face=Arial color=#0000ff
size=2>Thanks,</FONT></SPAN></DIV>
<DIV><SPAN class=160495903-01102004><FONT face=Arial color=#0000ff
size=2>Paul.</FONT></SPAN></DIV>
<DIV><SPAN class=160495903-01102004><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=160495903-01102004><FONT face=Arial color=#0000ff
size=2> </DIV>
<DIV><BR></DIV></FONT></SPAN><FONT face=Arial size=1>
<HR>
<P><STRONG>Attention: </STRONG>The information contained in this message
and/or attachments from AgResearch Limited is intended only for the persons or
entities to which it is addressed and may contain confidential and/or
privileged material. Any review, retransmission, dissemination or other use
of, or taking of any action in reliance upon, this information by persons or
entities other than the intended recipients is prohibited by AgResearch
Limited. If you have received this message in error, please notify the sender
immediately.</P>
<HR>
</FONT>
<P>
<HR>
<P></P>_______________________________________________<BR>Delphi mailing
list<BR>Delphi@ns3.123.co.nz<BR>http://ns3.123.co.nz/mailman/listinfo/delphi<BR></BLOCKQUOTE>
<FONT face=Arial size=1>
<HR>
<P><STRONG>Attention: </STRONG>The information contained in this message and/or
attachments from AgResearch Limited is intended only for the persons or entities
to which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or taking
of any action in reliance upon, this information by persons or entities other
than the intended recipients is prohibited by AgResearch Limited. If you have
received this message in error, please notify the sender immediately.</P>
<HR>
</FONT>
</BODY></HTML>