If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Replacing text in MS Word from ASP

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-16-03, 22:50
jamesO jamesO is offline
Registered User
 
Join Date: Sep 2003
Posts: 16
Angry 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
Reply With Quote
  #2 (permalink)  
Old 10-17-03, 14:18
Seppuku Seppuku is offline
Useless...
 
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On