Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CreateObject("Word.Application") - doesn't work? 1

Status
Not open for further replies.

albie101

Programmer
Oct 8, 2001
50
NZ
Hi all,

I am having a problem where I am trying to open a word application from an asp page. I have the following code:

dim wordDoc
set wordDoc = CreateObject("Word.Application")
wordDoc.Visible = true
wordDoc.Documents.Open("test.doc")

but it dies on the createobject call with the error:
Microsoft VBScript runtime (0x800A01AD)
ActiveX component can't create object: 'Word.Application'

Does anyone know why this occurs and how I can fix it?

Thanks
Em
 
I just had an idea and tried "server.CreateObject("Word.Application")".

Still no luck, but I now get a different error along the lines of "Invalid ProgID."

Can someone else please try this and see if they can make it work?

Thanks
Em
 
Getting Word to work through ASP is a tricky affair. I am guessing that your page is set up so that Word opens on the server. Microsoft doesn't really support using Office automation through ASP.

You may want to change that so that it opens on the client. The syntax is the same, just put <SCRIPT language=VBSCRIPT>
at the start and </SCRIPT> at the end.

Microsoft's Knowledge Base has some articles regarding this topic. I used this one (Q198703) to set up Excel automation and adapted it for Word.

Good luck.
Ann
 
Thanks Ann, I will give it a go using the client side stuff. I will also try installing it on the server.

Em
 
I went through the same thing, i purchased the book &quot;Instant ASP Scripts&quot; there was a asp application to create a word document on the server and send it to someone via email. but my server provider didn't have word installed, so it didn't work.
 
Here is a great article with examples of how to create a Word document with ASP. This method uses the File System Object to write the file, then sends a header to the browser to a redirect to the file name. So, you can either send the header to the browser so your dynamically created file will be requested by the client browser, or you can use a portion of this solution to just have ASP create the word document on the server then attach it to an email.

I always recommend that you run the full sample (or as much of it as you can) from this article on your application FIRST before trying to implement your own version of it. It always helps to start with MS sample code, get it up and working, then start to tweek it for your own needs.

You'll notice about half way down the example script this.
Code:
Response.Write _
       &quot;<META HTTP-EQUIV=&quot;&quot; .....
At this point, ASP has already created the Word document using the FSO. So, nobody says that you have to send a header to the browser to request the file. ASP has created an actual Word file on the server. You can use that to attach to emails, etc...


I've done similar things with Excel, but haven't tried Word yet. I'm interested to know how this turns out.


Now, this is an article on Word Automation on the client side. It pertains to setting up a Mail Merge, but can be used for many different functions, including just populating and formatting the document. I would stay away from automation unless it's totally necessary. Try to see if article #1 will work for you.


Hope this helps.

ToddWW :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top