• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 659
  • Last Modified:

Server Error

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
Nandhini
Asked:
Nandhini
  • 17
  • 14
  • 6
9 Solutions
 
Lord_McFlyCommented:
Do you have Word installed on the machine (server) where you are executing the page from?
0
 
ap_sajithCommented:
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
 
ap_sajithCommented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
NandhiniAuthor Commented:
Even though my server has msword installed,i get the error ' activex component couldn't be created'
0
 
Lord_McFlyCommented:
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
 
NandhiniAuthor Commented:
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
 
Lord_McFlyCommented:
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
 
NandhiniAuthor Commented:
what is metabase?how is it related to my problem?
0
 
Lord_McFlyCommented:
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
 
Lord_McFlyCommented:
Just in case you can't locate a place to download it...

http://support.microsoft.com/default.aspx?scid=kb;EN-US;232068
0
 
NandhiniAuthor Commented:
i would like to run my application in iis.how to edit the metabase so that it grants permission to read msword document
0
 
Lord_McFlyCommented:
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
 
Lord_McFlyCommented:
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
 
NandhiniAuthor Commented:
i installed metaedit.what's the next step
0
 
NandhiniAuthor Commented:
i couldn't open the metaedit registry file.it says'
a fatal error occured trying to access the registry' when i opened it
0
 
Lord_McFlyCommented:
Hmmm, what OS do you have you still didn't answer.

0
 
NandhiniAuthor Commented:
my os :windows98
0
 
Lord_McFlyCommented:
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
 
NandhiniAuthor Commented:
ASPAllowOutOfProcessComponents is not in that place.
then what should i do to run my appln in iis which is another machine
0
 
NandhiniAuthor Commented:
how to highlight text in a richtext control object?
0
 
Lord_McFlyCommented:
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
 
ap_sajithCommented:
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
 
ap_sajithCommented:
>>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
 
Lord_McFlyCommented:
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
 
NandhiniAuthor Commented:
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
 
NandhiniAuthor Commented:
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
 
NandhiniAuthor Commented:
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
 
Lord_McFlyCommented:
Do you need any more assistance on this question?
0
 
NandhiniAuthor Commented:
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
 
ap_sajithCommented:
what do you mean by rich text box?.

Are you using asp or Asp.NET?

Cheers!!
0
 
NandhiniAuthor Commented:
i am using asp
0
 
NandhiniAuthor Commented:
by rich text box i mean rich text editor
0
 
Lord_McFlyCommented:
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
 
NandhiniAuthor Commented:
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
 
Lord_McFlyCommented:
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
 
ap_sajithCommented:
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
 
NandhiniAuthor Commented:
thanks Lord_McFly

unchecking the option in IE helped me in tracing the error

great job
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 17
  • 14
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now