Solved

Server Error

Posted on 2004-04-19
37
645 Views
Last Modified: 2007-12-19
i used the following code to read a microsoft word document.i am getting error message 'activex component could not be created'.

<%
docpath = Server.MapPath("doc1.doc")
set word = createobject("Word.Application")
text = word.documents.open(docpath).Content.Text
word.quit
response.write(text)
%>

kindly suggest me a best way to read MSWord document.i need the complete code for the same

thanks in advance

0
Comment
Question by:Nandhini
  • 17
  • 14
  • 6
37 Comments
 
LVL 6

Assisted Solution

by:Lord_McFly
Lord_McFly earned 400 total points
Comment Utility
Do you have Word installed on the machine (server) where you are executing the page from?
0
 
LVL 21

Expert Comment

by:ap_sajith
Comment Utility
I had asked you check if you had word installed on the server before running the code. You need to have MS Word installed on the server from which your code is running.

Cheers!!
0
 
LVL 21

Accepted Solution

by:
ap_sajith earned 100 total points
Comment Utility
Try changing your code to..

<%
docpath = Server.MapPath("doc1.doc")
set word = Server.createobject("Word.Application")
text = word.documents.open(docpath).Content.Text
word.quit
response.write(text)
%>

Also, try running the asp page using an account that has admin privilages (Just to clarify that it is not a permissions issue).

Cheers!!
0
 
LVL 1

Author Comment

by:Nandhini
Comment Utility
Even though my server has msword installed,i get the error ' activex component couldn't be created'
0
 
LVL 6

Assisted Solution

by:Lord_McFly
Lord_McFly earned 400 total points
Comment Utility
It might be because you are using the wrong programID - what version of MS Word do you have?

The following covers MS Word 97 & 2000 if I remember rightly...

Set word = Server.CreateObject("Word.Application.8")
0
 
LVL 1

Author Comment

by:Nandhini
Comment Utility
i corrected the version number according to the msword installed in my machine.my server is pws.how to rectify the following error

Server object error 'ASP 0196 : 80040154'

Cannot launch out of process component

/test/Default.asp, line 13

Only InProc server components should be used. If you want to use LocalServer components, you must set the AspAllowOutOfProcComponents metabase setting. Please consult the help file for important considerations.
0
 
LVL 6

Expert Comment

by:Lord_McFly
Comment Utility
What OS are you on - if its 98 (I say that because you mention PWS) then I don't think 98 has a Metabase - but that aside in order to edit the property you need to get a copy of MetaEdit 2.0 - search the Microsoft site - its on the somewhere - its free. Get that far first.
0
 
LVL 1

Author Comment

by:Nandhini
Comment Utility
what is metabase?how is it related to my problem?
0
 
LVL 6

Assisted Solution

by:Lord_McFly
Lord_McFly earned 400 total points
Comment Utility
Its hard to explain - basically when the web server executes stuff its done within IIS memory space - or in the case of PSW I guess within its own memory space.

Because MS Word is an app it needs to lauch and this can't be done within IIS's own memory so it need to be aloud to be launch out of process - the setting is also a security setting - it stops the execution of apps on the server by scripts.

So in essence if you where providing web space to 3rd parties they could take avantage of this and run programs on your server that were lauched by ASP code.

Imagine this scenario - you can embed applications in a word document - this means that you could in effect upload the word document to the server then using Automation open the document and save out the program. I don't know exactly if this is possible but it is theoretically possible.

Anyway - try and find this MetaBase prog :)
0
 
LVL 6

Assisted Solution

by:Lord_McFly
Lord_McFly earned 400 total points
Comment Utility
Just in case you can't locate a place to download it...

http://support.microsoft.com/default.aspx?scid=kb;EN-US;232068
0
 
LVL 1

Author Comment

by:Nandhini
Comment Utility
i would like to run my application in iis.how to edit the metabase so that it grants permission to read msword document
0
 
LVL 6

Assisted Solution

by:Lord_McFly
Lord_McFly earned 400 total points
Comment Utility
If you're at all interested - you can read a little about 'Out Of Process Compnent'

http://www.microsoft.com/windows2000/techinfo/reskit/en-us/default.asp?url=/windows2000/techinfo/reskit/en-us/iisbook/c06_out-of-process_components.asp

:) You think you having trouble at the moment - you wait until you get it working - the MS Word DOM is a monster.

A tip for you -you will find the following handy if you get into a lot of Automation stuff.

In word you will find the Visual Basic Editor - from there you will be able to view the object broswer and have fun discovering the DOM, but its handy because it has all the contants (tucked away in it somewher) that you will need and command snytax.
0
 
LVL 6

Expert Comment

by:Lord_McFly
Comment Utility
Install it - Run it

You will find the parameter in the follwoing location...

LM/W3SVC/ASPAllowOutOfProcessComponents

At the mo I just checking exactly what it is you need to do - its been a while.
0
 
LVL 1

Author Comment

by:Nandhini
Comment Utility
i installed metaedit.what's the next step
0
 
LVL 1

Author Comment

by:Nandhini
Comment Utility
i couldn't open the metaedit registry file.it says'
a fatal error occured trying to access the registry' when i opened it
0
 
LVL 6

Expert Comment

by:Lord_McFly
Comment Utility
Hmmm, what OS do you have you still didn't answer.

0
 
LVL 1

Author Comment

by:Nandhini
Comment Utility
my os :windows98
0
 
LVL 6

Assisted Solution

by:Lord_McFly
Lord_McFly earned 400 total points
Comment Utility
I did say that maybe Win98 didn't have a Metabase - but I did read that the setting my well be in the Registry.

Ok, I'm not a 100% sure but load regedit and nav to the following place, if its not there then I don't know where it is...

HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/W3SVC/ASP/Parameters

If this is the right place then you will see the ASPAllowOutOfProcessComponents, however it could be in any of the folder under W3SVC - I know its right up til that point.

If you do find it then Value should be 1 - the Default is 0.

If its not there at all then you'll have to accept that that you're not going to be able to do it on you Win98 machine.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Author Comment

by:Nandhini
Comment Utility
ASPAllowOutOfProcessComponents is not in that place.
then what should i do to run my appln in iis which is another machine
0
 
LVL 1

Author Comment

by:Nandhini
Comment Utility
how to highlight text in a richtext control object?
0
 
LVL 6

Expert Comment

by:Lord_McFly
Comment Utility
I'm not even sure what you are refering to sorry.

By the way if you want to paste in the code you have got so for the Word stuff I could test what you have and let you know whether the error was produced by you machine or the code.
0
 
LVL 21

Expert Comment

by:ap_sajith
Comment Utility
Hi  Nandhini, Are you doing this for learning purposes?. If not, i would suggest  that you change your OS from Win98 to XP pro or Win2k. PWS is not that robust when compared to IIS.

By the way, if you let us know the purpose of your app (reading from a word doc), we can suggest an alternative / better method. If you have read my other post, you would have understood by now that using office automation components are not advisable.

@Lord_McFly: Please refrain from suggesting hacks (especially registry editing) without actually warning the user that it might cause your server to crash. So that atleast the user is cautious about doing it. ;o)

Cheers!!
0
 
LVL 21

Expert Comment

by:ap_sajith
Comment Utility
>>how to highlight text in a richtext control object<<

No clue what you are talking about. Are you referring to a RTE as found in hotmail & Yahoo?

Cheers!!
0
 
LVL 6

Expert Comment

by:Lord_McFly
Comment Utility
ap_sajith

If I make a reference to registry changes then I will ensure that I include a statement to the effect of what you mentioned, however this is not a hack as you suggest.
0
 
LVL 1

Author Comment

by:Nandhini
Comment Utility
Let me be more clear abt my appln
i am developing search engine using asp
we have group of .doc , .rtf files in a folder
the search engine searches for the presence of keywords in these group of files and stores the filenames.
when the user clicks the filename it should be opened in a richtext box with the keywords highlighted
0
 
LVL 1

Author Comment

by:Nandhini
Comment Utility
when i executed set wrd = Server.CreateObject("Word.Application.8")
i received the following error

Error Type:
Server object, ASP 0178 (0x80070005)
The call to Server.CreateObject failed while checking permissions. Access is denied to this object.
/nandini/Search Engine/Default.asp, line 22

system configuration
server : iis
os : windows2000

word is installed in the server
(word version-2000)

how to rectify this problem? it is very urgent. i am wholly dependent on this site

0
 
LVL 1

Author Comment

by:Nandhini
Comment Utility
hello ap_sajith
u have said that using automation object is not advisable. then how to read a word document ,search it
i have to also provide means for the users to view the word document with some changes made to it.(changes in the sense color of the keywords would be changed)
0
 
LVL 6

Expert Comment

by:Lord_McFly
Comment Utility
Do you need any more assistance on this question?
0
 
LVL 1

Author Comment

by:Nandhini
Comment Utility
i solved the 'access denied' problem
i need another help
i have already explained my application
i have completed upto the section of displaying the filenames
now when the user clicks the filename, it should be loaded into a richtextbox
how to code this section?
help me
0
 
LVL 21

Expert Comment

by:ap_sajith
Comment Utility
what do you mean by rich text box?.

Are you using asp or Asp.NET?

Cheers!!
0
 
LVL 1

Author Comment

by:Nandhini
Comment Utility
i am using asp
0
 
LVL 1

Author Comment

by:Nandhini
Comment Utility
by rich text box i mean rich text editor
0
 
LVL 6

Assisted Solution

by:Lord_McFly
Lord_McFly earned 400 total points
Comment Utility
Ok, the following will open the word document and store the contents in a variable.

<%@ Language=VBScript %>
<%Option Explicit%>
<%
Dim objDoc
Dim sContent

Set objDoc = Server.CreateObject("Word.Application.8")      <--- substitute this with the ProgID that you got yours working with.

objDoc.Documents.Open Request.ServerVariables("APPL_PHYSICAL_PATH") & "Misc\Test_Document.doc"   <--- substitute this with your own path to file.

objDoc.Selection.WholeStory
objDoc.Selection.Copy

sContent = objDoc.Selection    <-- Contents of Word document is here, use as you will.
Response.Write sContent

objDoc.ActiveDocument.Close
objDoc.Application.Quit

Set objDoc = Nothing
%>

Ok - Hopefully that answers the question of 'reading' a word document which was your original question - the question about how to code a RichTextBox should be posted as a new question. I would suggest that if you are only searching the contents of the Word document then there isn't a need for the rich text box, a normal <textarea> should do the trick.

0
 
LVL 1

Author Comment

by:Nandhini
Comment Utility
hi Lord_McFly,

your code takes a long time to execute

so that i get HTTP 500-internal server error

do u have any other way to read a word document without consuming much resources
0
 
LVL 6

Assisted Solution

by:Lord_McFly
Lord_McFly earned 400 total points
Comment Utility
Personaly I don't know of another way to open a Word doc so you can read the contents, I'm not saying there isn't one - thats just the only way I know.

If you use IE can you do the following...

Tools - Internet Options - Advanced tab...

Under the Browsing section untick 'Show friendly HTTP error message'

Then get the error - it should give a better description of the error - if your getting a HTTP error then its not working anyway.

Cheers
0
 
LVL 21

Expert Comment

by:ap_sajith
Comment Utility
I think you are asking for too much from asp. Its not advisable to use office components on a webserver and i dont think any of the hosted servers would have that feature.. unless you have your own dedicated hosting account. Maybe you are looking for a much more complex system like a content management system or a document management system. Or maybe even index server for document search!.

Cheers!!
0
 
LVL 1

Author Comment

by:Nandhini
Comment Utility
thanks Lord_McFly

unchecking the option in IE helped me in tracing the error

great job
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now