-
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 :)
-
hi
I believe you will have to use Scripting.FileSystemObject.:)
-
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?
-
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.
-
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
-
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)
-
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.
-
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
-
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.
-
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
-
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?
-
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
-
:) Looks like you weren't being so stupid ;)
I just assumed there was a copy of office 97 on the server, I'll have to sort out a licence.
Thanks for you time :)