Forum Moderators: open
I'm trying to read the text from a Word file using ASP and OpenTextFile then add it to the end of a new word document that has some text already.
When I do this the added Word info comes out as?! etc etc...
I used the code below
Const ForReading = 1, ForWriting = 2, ForAppending = 8, TristateUseDefault=-1
filedir=Server.MapPath("../" & Filenumb(1))
Set filesys = CreateObject("Scripting.FileSystemObject")
If filesys.FileExists(filedir) Then
Set filetxt = filesys.OpenTextFile(filedir, ForReading, False, TristateUseDefault)
cvtext=filetxt.ReadAll
filetxt.Close
Set wfile = filesys.CreateTextFile(filedir, True)
wfile.Write (thetext)
wfile.close
I also tried just adding the text to the end of the Word file but there was no change to the file, (permissions set to allow write on the folder)
Const ForReading = 1, ForWriting = 2, ForAppending = 8, TristateUseDefault=-1
filedir=Server.MapPath("../" & Filenumb(1))
Set filesys = CreateObject("Scripting.FileSystemObject")
If filesys.FileExists(filedir) Then
Set filetxt = filesys.OpenTextFile(filedir, ForAppending)
filetxt.writeline("Test")
filetxt.Close
It seems to work with txt files but not Word.
Any ideas?
Alan
There are some links at the bottom for 3rd party component vendors.
You could also consider client-side automation of Word if its an intranet or extranet or controlled environment.