Forum Moderators: open

Message Too Old, No Replies

Convert .doc files to .txt on asp server

i.e. not offline

         

robster124

12:33 am on Feb 6, 2005 (gmt 0)

10+ Year Member



I'm at my wit's end here after searching usenet archives and the dregs of the internet for hours today.

What I want to do is quite simple. I want to run a script (don't mind what type) that will convert .doc files which are stored on my asp windows server to .txt files. It must be done on the server and by the server, in other words, I don't want to be downloading the files locally and executing batch processes.

This must be possible. After all, you can do anything with Access database files on Windows server! Why not its Office sister - Word!

I'm so desperate to do this I'm prepared to hear how this can be done on Apache/UNIX servers too - I may switch if it it only possible on that platform!

As I said, any language script is OK...

Any help here, would be much much appreciated.

duckhunter

3:44 am on Feb 6, 2005 (gmt 0)

10+ Year Member



I've done some work automating Office and it's not an easy road. First off you have to install Office on your server (not recommmended) to get the executables needed to open the stuff. Once you have it open with a Word object, you can SaveAs/format text.

The biggest problem, you will find is terminating the instance of Word you just created. Big bad memory leak problems since it runs out of process. Below is the only stable way I was able to do it, mind you I was doing it in a .NET service, not inside IIS. The attempts made in VB6 (read ASP) failed because of memory problems. I've pasted some .NET code samples below.

Dim oWord As Word.ApplicationClass
Dim oDoc As Word.DocumentClass

oWord = New Word.ApplicationClass()
oDoc = New Word.DocumentClass()
oDoc = oWord.Documents.Open("C:\FileToOpen.doc")
oDoc.SaveAs("C:\MyFile.txt", wdFormatText) 'Here's where you can specify format
oDoc.Close
oWord.Quit
oDoc = Nothing
oWord = Nothing

Good luck, it's a messy situation to be in. Glad I don't support that application any more ;)

robster124

9:28 pm on Feb 6, 2005 (gmt 0)

10+ Year Member



Thanks duckhunter. I feared that installing office on the server would be the only way forward.

I think I'm going to have to pursue the offline local route...

aspdaddy

11:25 am on Feb 7, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Theres info and links to components in this article

[support.microsoft.com...]