Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: ASP -> Replace words in a Word Doc


Message #1 by "James" <james.haslam@b...> on Mon, 15 Apr 2002 19:15:17
Hi,

I'm trying to get a word document to open up another word document, change 
some of the words, and save it as a new document.

I have successfully been able to create the new doc, add the existing doc 
to it, save it, and close it...but I am failing in being able to replace 
the words I need to change.

Here is the code I have so far (it fails on the replace line):


WordDocPath = Server.MapPath("Docs")
TemplateDocument = WordDocPath + "\Template_Document.doc"
CompiledDocument = WordDocPath + "\Compiled.doc"

Set WordApp = CreateObject("word.application")
Set WordDoc = WordApp.Documents.Add(TemplateDocument)

WordApp.Application.Visible = False

Set MyRange = WordDoc.Application.ActiveDocument.Content.Find
MyRange.Execute FindText:="<find>", ReplaceWith:="<replaced>", 
Replace:=wdReplaceAll


WordDoc.SaveAs CompiledDocument 
WordDoc.Close
WordApp.Quit


Any ideas what the replace line should be?
Thanks!  
Message #2 by "Ken Schaefer" <ken@a...> on Tue, 16 Apr 2002 19:36:26 +1000
This is an ASP & Access list. What does you question have to do with ASP &
Access?

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "James" <james.haslam@b...>
Subject: [access_asp] ASP -> Replace words in a Word Doc


: I'm trying to get a word document to open up another word document, change
: some of the words, and save it as a new document.
:
: I have successfully been able to create the new doc, add the existing doc
: to it, save it, and close it...but I am failing in being able to replace
: the words I need to change.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


  Return to Index