homepage Welcome to WebmasterWorld Guest from 54.242.18.190
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
Reaing Word using OpenTextFile
I just get nonsense returned
Condor12




msg:947939
 11:03 am on Apr 8, 2005 (gmt 0)

Hi,

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

 

aspdaddy




msg:947940
 12:35 pm on Apr 8, 2005 (gmt 0)

openTextFile does not read word documents, you need a component to do this.

Condor12




msg:947941
 12:44 pm on Apr 8, 2005 (gmt 0)

Thanks aspdaddy,

I suppose that makes sense, (openTEXTfile!)

Any idea what component I would need?

Thanks

Alan

aspdaddy




msg:947942
 9:01 am on Apr 9, 2005 (gmt 0)

The component is the Word.Application BUT take a look at this first.
INFO: Considerations for Server-Side Automation of Office [support.microsoft.com]

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.

snookie




msg:947943
 3:03 pm on Apr 9, 2005 (gmt 0)

I think to use the Word.Application that you'll need to have Word on the server that is handling the file. We only ever handled client-side using VBScript. I dunno but you maybe able to use wordpad components to handle the file?

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved