Thanks for your help Allen and Brian - StoryRanges did the trick.
 
Regards,
Paul.


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Brian Wrigley
Sent: Friday,October,01,2004 5:11 p.m.
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] Word Automation

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):
 
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.
 
For Each myStoryRange In ActiveDocument.StoryRanges
    myStoryRange.Find.Execute FindText:="Microsoft Word", Forward:=True
    While myStoryRange.Find.Found
        myStoryRange.Italic = True
        myStoryRange.Find.Execute FindText:="Microsoft Word", Forward:=True
    Wend
    While Not (myStoryRange.NextStoryRange Is Nothing)
        Set myStoryRange = myStoryRange.NextStoryRange
        myStoryRange.Find.Execute FindText:="Microsoft Word", Forward:=True
        While myStoryRange.Find.Found
 
            myStoryRange.Italic = True
            myStoryRange.Find.Execute FindText:="Microsoft Word", Forward:=True
        Wend
    Wend
Next myStoryRange
 
(End of example)
 
 
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.
 
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.
 
Regards,
Brian
 
----- Original Message -----
Sent: Friday, October 01, 2004 4:08 PM
Subject: [DUG] Word Automation

I'm using Word automation to create a report.
Opening a template file, and using Find/Replace to substitute various tokens with real data.
 
This sort of thing seems to work:
 
WordDoc1.Content.Find.Execute(vSearchText, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam,
                                                EmptyParam, vWrap, EmptyParam, vReplaceText, vAll, EmptyParam,
                                                EmptyParam, EmptyParam, EmptyParam);
 
But it only finds and replaces in the body of the document, not in the header or footer sections.
 
Can anyone tell me what I need to do?
 
Thanks,
Paul.
 
 


Attention: 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.



_______________________________________________
Delphi mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/delphi

Attention: 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.


_______________________________________________
Delphi mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/delphi

Reply via email to