Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2003
    Posts
    16

    Angry Unanswered: Replacing text in MS Word from ASP

    Hello

    I am trying to open an MS Word document from an ASP page then use search and replace to modify the letter (e.g. name and address). I want to do this because of the control over the look and feel of the final letter.

    The code I am attempting is:
    Code:
    set letter = CreateObject("Word.Application") 
    letter.Documents.Open("letter.doc")
    
    letter.Documents(1).Content.Select
    with letter.Documents(1).Selection.find
    	.Clearformatting
    	.Forward = true
    	.Wrap = wdWrapContinue
    	.Execute FindText:=strFind, Replace:=wdReplaceAll, ReplaceWith:=strReplace
    end with
    When I execute it I get an 'Expected Statement' error and the debugger is pointing at strFind.

    What am I doing wrong?

    Regards
    James

  2. #2
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721

    Re: Replacing text in MS Word from ASP

    I've never used this in ASP before, but it looks like you need double quotes around the text after "Execute"

    Code:
    .Execute "FindText:=strFind, Replace:=wdReplaceAll, ReplaceWith:=strReplace"
    That which does not kill me postpones the inevitable.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •