Problems with creating a Word Document on a server

I am trying to create a Word document on my server through an ASP.

I keep getting an error message 80020009 System cannot find path specified.

        wordApp.visible = false  
        MyDocName = "C:\Learn_Style1.doc"
        WordDoc = wordApp.documents.Open(MyDocName)

It appears the error is on the visible = false statement.

I ran the code on my local PC to get it working, then converted it to a DLL to run in an ASP page.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


I would try checking if the file exist using the DIR command. It could be that IIS can not see outside off its folder. Try looking at the folder securities might be a bit of a red herring but I know you have to set the folders up in iis.

I would put the word document in a folder off of the asp folder and use the map server command I will post an example

Try this then move the word doc into a folder off of the main app called docs then try this code

wordApp.visible = false  
MyDocName = Server.MapPath("DOCS\Learn_Style1.doc")
WordDoc = wordApp.documents.Open(MyDocName)

housercAuthor Commented:
My problem seems to be in the path to WORD on my server.

Is there anything I need to do to get my DLL to "see" where word is on the server?

This ASP works fine on my local machine, so the functionality is there, it just can't find the WORD application on the server.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Intresting, You may have to open up the OFFICE folder on the IIS server. I think you add the folder as a virtual server.

This example seems to confirm you code is correct and the process should work
Also what error are you getting?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
housercAuthor Commented:
The message I'm getting is;

CREATEFORMS error '80020009'

Runtime error occurred in Program CREATEFORMS at Line 28: Access is denied. (0x80070005)

I've got my DLL running under the profile of an administrator on the server, the document is accessable to everyone.
housercAuthor Commented:
Also, line 28 use to be;

Application.visible = false

Now it is;


And I'm still getting the same error.

Is there a setting on the server that limits Word processing?
housercAuthor Commented:
I tried running the example you gave me above and I get this message;

Microsoft Word error '800a16c1'

Object has been deleted.

/mydoc.asp, line 5
housercAuthor Commented:
I ran dcomcnfg.exe and set the identity to run under the same user all the time. Now, I'm getting the following error:

Microsoft VBScript runtime error '800a0046'

Permission denied: 'CreateObject'

/mydoc.asp, line 4

Any help would be appreciated.
housercAuthor Commented:
This has been increased point wise.
housercAuthor Commented:
The answer is that Microsoft never meant for Office applications to run from a server. Microsoft documented it very well on their website and states 5 major reason for NOT using Word, or anything Office product, from the server.

One of these is scalability, one is that the products were never meant to be run anywhere but on a desktop and need a profile to run, and one that I had not even considered was that fact that Office Applications have no security built in. The last one means that anybody, outside of your office using the application, could do severe damage.

So, I'm off to looking to other avenues.

I'm awarding the points to MrPan, since he was the only one that replied and tried to assist me.  Thank's MrPan!
Thanks for the points you could look at something like activePDF which I use for generating PDFs on the fly. It might be a bit pricy but there are other similar products out there.

I think their website is
You could try writing that data to a table in a database. Monitor the file with a program not running on the web server. Create the document (from the data) and then ftp the word document to the server.
housercAuthor Commented:
What I did in this instance was;
Save the Word document as HTML.
Convert the HTML to XSLT
Then substituted in the variables from an XML document
and used FSO to save the object prior to displaying it.

PDF would have been cleaner and easier, but my client wanted them to be word documents.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.