CreateObject("Excel.Application") fails after upgrading Excel on server from 97 to 2003

This server side VB script
Set objExcel = CreateObject("Excel.Application")  '  Create an Excel object.
            objExcel.Application.Visible = true
            objExcel.Application.UserControl = true
fails with error
ActiveX component can't create object: 'Excel.Application'

after upgrading Office from 97 to 2003 on the server.  

App is opening Excel on server, generating file, saving it, and then emailing it to user.  After reading it appears it could be a permission issue for the account generating the excel process????

Thanks!
okcuserAsked:
Who is Participating?
 
NorushConnect With a Mentor Commented:
Actualy my advice of order should be otherwise.

First try installing the office web components which should indeed solve your problems.

If it still does not work then you can go for option 2 with the iusr_servername login.
Change the servername password in the user-management so you can login with that user.
For a correct procedure to set the correct password back for this user you can check the following links:

- http://www.experts-exchange.com/Software/Server_Software/Web_Servers/Microsoft_IIS/Q_22955181.html
- http://www.howtonetworking.com/internet/resetpassword.htm
0
 
okcuserAuthor Commented:
When I run the page - I can look on the server and see the Excel.exe process created with my user account (I'm running from my desktop).  It will sit for a few minutes and then come back with the ActiveX component can't create object: 'Excel.Application' error.  Then the Excel.exe process is gone.
0
 
NorushCommented:
Try with:
			Set objExcel = Server.CreateObject("Excel.Application")  '  Create an Excel object.
            objExcel.Application.Visible = true
            objExcel.Application.UserControl = true

Open in new window

0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
okcuserAuthor Commented:
Thanks, but I already tried that and got this error:

Server.CreateObject Failed

Any other ideas?
0
 
NorushCommented:
Can you show the entire errormessage you are getting when using my code ?
0
 
exx1976Commented:
+1, I use Excel 2003 for all my automation routines, here's the code I use to get it rolling..


Set oExcelApp = CreateObject("Excel.Application")
Set oWorkbook = oExcelApp.Workbooks.Open(FilePath)
Set oWorksheet = oWorkbook.Worksheets(1)
oWorksheet.Activate
oExcelApp.Visible = False

Open in new window

0
 
okcuserAuthor Commented:
Norush - here is the exact error:
Server object error 'ASP 0177 : 80080005'
Server.CreateObject Failed
/isys/pc_HulkShipping.asp, line 45
80080005

when I run the following code:
'  Automate Excel to insert the built up string.
<%Set objExcel = Server.CreateObject("Excel.Application")  '  Create an Excel object.      
objExcel.Application.Visible = true
objExcel.Application.UserControl = true%>

This is all run inside <%@ Language=VBScript%>

Line 45 (where it fails) is the server.createobject line.  

When I look on the server a DW20.exe and Excel.exe process are created with my user account (running asp page on my machine) on the webserver.  When the application errors out, the excel.exe process goes away but the dw20.exe processes stay until I end them.  

exx1976 - I believe my code is almost the same as yours except that I'm not opening an existing excel document, but just creating a new one.  Here is the rest of my code - please look and see if I'm missing something.

Set objExcel = Server.CreateObject("Excel.Application")  '  Create an Excel object.
objExcel.Application.Visible = true
objExcel.Application.UserControl = true
                                          
Set ExcBook = objExcel.Workbooks.Add()
vSheetNum = 0
With ExcBook
     .Worksheets.Add
     .Sheets(1).Select
     .Sheets(1).Name = "Shipping"
...
     'Save
     .SaveAs FileName
     .Close
End With
'free resource                  
objExcel.Quit
Set ExcBook= Nothing    
Set objExcel = Nothing

This code worked until I upgraded the Office 97 on the webserver to office 2003.  My account is an administrator on the webserver so it would seem it isn't a permission issue since the processes are showing as created with my account.  

Thanks!
0
 
exx1976Connect With a Mentor Commented:
Code looks good to me..

But, if you're running this on a webserver, I know that Office 2003 does use ActiveX in order to render the pages..   It's been a LONG time, but have a google for SharePoint and Office.  I recall having to download some ActiveX controls in order to display Office content on my SharePoint server for users who do not have Office..  You didn't mention anything about SharePoint, but hopefully it will lead you to the ActiveX pieces you need..


HTH,
exx
0
 
NorushCommented:
Two possible solutions:
1) log on as this anonymous internet user to the os (instead of using your own user id) on the IIS machine, then start Excel, wait for the msi-part to finish. Then start as the regular user again and your asp page should work
2) use a different user then anonymous login for this website, preferrably one which has started Excel once on the IIS machine otherwise you have to execute solution 1 for this user too
3) Download Office Web Components at http://www.microsoft.com/downloads/details.aspx?FamilyId=7287252C-402E-4F72-97A5-E0FD290D4B76&displaylang=en
0
 
NorushCommented:
Actualy thats 3 possible solutions :)
0
 
okcuserAuthor Commented:
We do have a sharepoint server, but are still getting it set up.  I'm not actually displaying the Excel document after it is created, but instead just creating the file, saving it, closing excel, and emailing the file to the user as an attachment.  For word documents I have it open the word on their computer.  I'd like to have it open excel on their workstation as well, but for some reason it doesn't.  However, since I know what version of excel is on the server it works this way too (if I can get it to work again).

So, Norush, if I understand correctly, it is because IIS is using the anonymous iuser account to create the object that it won't let it work - is that because Office 2k3 has more security than 97?  So, if I log into the webserver as iuser_servername and start excel?  What is the pwd?  Or download and install the office web components onto the web server?  

I figured out that the dw20.exe process is an error process and checked the event viewer.  Attached is the errors generated in the web server application log when I try to run this page.
weberrors.txt
0
 
okcuserAuthor Commented:
Norush - one more question

"log on as this anonymous internet user to the os (instead of using your own user id) on the IIS machine, then start Excel, wait for the msi-part to finish. Then start as the regular user again and your asp page should work"

I'm not logged in with my account on the webserver/iis machine - it is logged in with a local admin account.  The excel.exe process is started with my account because I'm running the asp page from my personal workstation that is logged in w/ my user account.

0
 
NorushCommented:
Yes okcuser, but the IIS-service runs under the anonymous internet user acount. Thats why i proposed that.
0
 
okcuserAuthor Commented:
Forgive me for being dense, it's been a long week already ... if I log into the webserver using the iusr_servername account, what password do I use?  I tried it with no password and it didn't work.  Since that account was created automatically I wasn't sure what it uses.

2nd question - if I download the office web components, will I need to change my code to use them or will that enable the activex controls so that the existing page works?  
0
 
okcuserAuthor Commented:
Well - I realized that after installing Office 2003, I never forced the windows update to run all the patches.  Once that was completed the application worked.  In the meantime, I had given the iuser account priv to the wwwroot folder as well.  

Thanks so much to both of you for your help!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.