Solved

Server Error

Posted on 2004-04-19
37
648 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
ID: 10857365
Do you have Word installed on the machine (server) where you are executing the page from?
0
 
LVL 21

Expert Comment

by:ap_sajith
ID: 10857428
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
ID: 10857462
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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 1

Author Comment

by:Nandhini
ID: 10858234
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
ID: 10858266
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
ID: 10865644
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
ID: 10865663
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
ID: 10865681
what is metabase?how is it related to my problem?
0
 
LVL 6

Assisted Solution

by:Lord_McFly
Lord_McFly earned 400 total points
ID: 10865718
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
ID: 10865738
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
ID: 10865785
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
ID: 10865802
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
ID: 10865809
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
ID: 10865937
i installed metaedit.what's the next step
0
 
LVL 1

Author Comment

by:Nandhini
ID: 10866180
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
ID: 10866215
Hmmm, what OS do you have you still didn't answer.

0
 
LVL 1

Author Comment

by:Nandhini
ID: 10866310
my os :windows98
0
 
LVL 6

Assisted Solution

by:Lord_McFly
Lord_McFly earned 400 total points
ID: 10866350
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
 
LVL 1

Author Comment

by:Nandhini
ID: 10866446
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
ID: 10868435
how to highlight text in a richtext control object?
0
 
LVL 6

Expert Comment

by:Lord_McFly
ID: 10868478
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
ID: 10875165
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
ID: 10875172
>>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
ID: 10875199
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
ID: 10875644
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
ID: 10877722
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
ID: 10877807
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
ID: 10885440
Do you need any more assistance on this question?
0
 
LVL 1

Author Comment

by:Nandhini
ID: 10886752
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
ID: 10906057
what do you mean by rich text box?.

Are you using asp or Asp.NET?

Cheers!!
0
 
LVL 1

Author Comment

by:Nandhini
ID: 10935400
i am using asp
0
 
LVL 1

Author Comment

by:Nandhini
ID: 10935432
by rich text box i mean rich text editor
0
 
LVL 6

Assisted Solution

by:Lord_McFly
Lord_McFly earned 400 total points
ID: 10940574
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
ID: 10946507
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
ID: 10946572
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
ID: 10946850
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
ID: 10947215
thanks Lord_McFly

unchecking the option in IE helped me in tracing the error

great job
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

809 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