ASP, DOC, RTF, ADODB.Stream, ContentType, BinaryWrite, and ReplaceB()

B

Bill

I'm using the example shown at :
http://support.microsoft.com:80/support/kb/articles/q276/4/88.asp

It involves using ASP/VbScript and ADODB.Stream to read binary data from a
*.DOC or *.RTF
file and then send it to the user with Response.ContentType and BinaryWrite.

Everything works fine until I try to Replace() certain strings in the *.RTF
file with my own
data. I'm assuming Replace() is choking on the binary characters, or
incorrectly thinking 0x00 values are
marking end of string.

Is there some kind of ReplaceB() function that I can use instead of lines
#10 and #11?

1> Set fs = Server.CreateObject("ADODB.Stream") ' Since FileSystemObject
can't read binary data
2>
3> fs.Type = 1 ' adTypeBinary=1
4> fs.Open
5> fs.LoadFromFile fNameFull
6> fullDoc = fs.Read
7> fs.Close
8> Set fs = Nothing
9>
10> fullDoc = Replace(fullDoc, "%g_name%", "Joe Smith")
11> fullDoc = Replace(fullDoc, "%g_date%", "12-31-2004")
12>
13> Response.Buffer = vbTrue
14> Response.ContentType = "application/msword" ' or "application/rtf"
15> Response.BinaryWrite fullDoc
16> Response.Flush
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top