|
-
Mar 20th, 2002, 03:44 AM
#1
Thread Starter
Fanatic Member
Word
Lets says...
I have a word document on my webserver. How can I open the word document (using ASP ), read/stream the contents to an array or something... and then close the document just as if it was a text file.
I've looked around the net and I've found several references to creating a word file, opening word and opening word document in browser window, but not reading the contents.
Hope someone can help
-
Mar 20th, 2002, 03:59 AM
#2
PowerPoster
hi
I believe you will have to use Scripting.FileSystemObject.
-
Mar 20th, 2002, 04:21 AM
#3
Thread Starter
Fanatic Member
Thanks for the speedy reply.
I've tried that before, it only returns a bunch of ÐÏࡱá>* due to word having its own document encoding.
Do you have any code I can try?
-
Mar 20th, 2002, 06:19 AM
#4
PowerPoster
OMG,
I just tried filesystemobject and read a word file - damn thing retrusn that junk-never realised that with wird it messes up.
Sorry - I just gave u a suggestion without checking it.
However, I will try to look for a possible soln. or work around
Will post it back if I find any.
-
Mar 20th, 2002, 06:25 AM
#5
Thread Starter
Fanatic Member
No probs
I got the same thing. Word docs aren't just a pure text so filesystemobject wont work, I just cant find another way to do it.
Thanks for you help
-
Mar 21st, 2002, 03:33 AM
#6
Thread Starter
Fanatic Member
anyone else got any ideas because this has got me stuck. I've tried this but always returns an error
Set oWord = CreateObject("Word.Application")
Set oDoc = oWord.Documents.Open(server.mappath("sample.doc"), ,
True)
Last edited by punkpie_uk; Sep 17th, 2002 at 06:23 AM.
-
Mar 21st, 2002, 09:29 AM
#7
Hyperactive Member
Yuch - this took a while....
firstly changed your code to - say
<%
Set oWord = Server.CreateObject("Word.Application")
Set oDoc = oWord.Documents.Open(server.mappath("sample.doc"), , True)
%>
and wrote is to the server - then created (in word) a 1 line test doc with "this is a test" and called it sample.doc and placed it in the same subdir- on running got a horrid error saying that the setup doesnt allow AspAllowOutOfProcComponents.
ok - this might be dodgy but tried what microsoft said on their site - see http://support.microsoft.com/default...;EN-US;q184682
myself i did in a prompt
C:\WINNT\system32\inetsrv\adminsamples adsutil set w3svc/AspAllowOutOfProcComponents True
and allowed it - then just for good measure restarted the webserver
net stop iisadmin /y
net start w3svc
then ran the script - finished ok!!! - seems to have loaded the wordk object & my doc - now need to pull the text - so changed the script to
<%
Set oWord = Server.CreateObject("Word.Application")
Set oDoc = oWord.Documents.Open(server.mappath("sample.doc"), , True)
mytext = Odoc.Paragraphs(1)
response.write mytext
%>
Pointed the browser at my new script and it spat out "this is a test" - my text from the doc (well first para....) - done
I would however be concerned at the implications of the change to allow "AspAllowOutOfProcComponents" True
Perhaps somebody with a better perpective can comment with the implication for this change
Is that what you were looking for or have I "truely gone fishing".....
Cheers, A.J.P.
-
Mar 21st, 2002, 05:23 PM
#8
Thread Starter
Fanatic Member
Yes, that should be what I need.
Thanks a lot, it looks like you've put a lot of work into it, cheers
It should ok editting that because its only on an Intranet where the end users are also only slightly computer literate
I'll try it tommorow when I'm back at work and I'll post if it works ok
-
Mar 22nd, 2002, 02:08 AM
#9
PowerPoster
hi
jpritchard - Thanks for the hard work.
From the explanation above , I gather that one needs to set the value of AspAllowOutOfProcComponents to true.
From what I gather from the link u have posted in your reply that in IIS 4.0 it was by default false but in IIS 5.0 it is by default set to true.
I am using IIS 5.0 but still the previous script didnt work, I will try it again though.
Just thought of pointing it out.
Thanks again.
-
Mar 22nd, 2002, 03:38 AM
#10
Hyperactive Member
hi -
yes sorry - absolutley correct - Im on IIS4 and what you said about II5 is true. (Im in the process of encouraging our tech area to move (allow) us to upgrade but expect this to be sometime just before the sun runs out of fuel and goes nova!!....) 
I'm interested in any errors you get - Other than obvious stuff I would start guessing that if this doesnt work, its worth looking at what IUSR etc can do with regard to the .DOC or the objects (ole32.dll & word) used etc etc - But I always seem to get lost if involved with permissions...... But it would be my first guess.
no probs - cheers, A.J.P
-
Mar 22nd, 2002, 04:01 AM
#11
Thread Starter
Fanatic Member
Hi,
I set AspAllowOutOfProcComponents to true and restarted the webserver but I get another error which I'm sure is something completely different.
Server object error 'ASP 0177 : 800401f3'
Server.CreateObject Failed
/test/read.asp, line 10
Invalid class string
I thought it was jsut a permissions thing with the HKEY_CLASSES_ROOT folder in the registry so I changed permissions and allowed IUSR full control but to no avail.
Any ideas?
-
Mar 22nd, 2002, 04:32 AM
#12
Hyperactive Member
hi
I guess that line 10 is the where (Word.Application) is used?
sorry if I am being stupid but is there a full copy of Word loaded on the server - if so do you have access to it (the server) and can you kick open regedit - if so do a find on "Word.Application" you should find it - if not something is amiss with the setup?
Usually for me the invalid class string means that the object isnt loaded on the server (or cannot be loaded for some reason - not registered?)
hope that helps - if not sorry
-
Mar 22nd, 2002, 05:51 AM
#13
Thread Starter
Fanatic Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|