Results 1 to 13 of 13

Thread: Word

  1. #1

    Thread Starter
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645

    Question 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
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

  2. #2
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089

    hi

    I believe you will have to use Scripting.FileSystemObject.

  3. #3

    Thread Starter
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    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?
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

  4. #4
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089
    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.

  5. #5

    Thread Starter
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    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
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

  6. #6

    Thread Starter
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    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.
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

  7. #7
    Hyperactive Member
    Join Date
    Feb 2001
    Posts
    280
    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.

  8. #8

    Thread Starter
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    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
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

  9. #9
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089

    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.

  10. #10
    Hyperactive Member
    Join Date
    Feb 2001
    Posts
    280
    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

  11. #11

    Thread Starter
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    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?
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

  12. #12
    Hyperactive Member
    Join Date
    Feb 2001
    Posts
    280
    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

  13. #13

    Thread Starter
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    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
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width