Link to home
Start Free TrialLog in
Avatar of okcuser
okcuser

asked on

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!
Avatar of okcuser
okcuser

ASKER

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.
Try with:
			Set objExcel = Server.CreateObject("Excel.Application")  '  Create an Excel object.
            objExcel.Application.Visible = true
            objExcel.Application.UserControl = true

Open in new window

Avatar of okcuser

ASKER

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

Server.CreateObject Failed

Any other ideas?
Can you show the entire errormessage you are getting when using my code ?
+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

Avatar of okcuser

ASKER

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!
SOLUTION
Avatar of exx1976
exx1976
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
Actualy thats 3 possible solutions :)
Avatar of okcuser

ASKER

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
Avatar of okcuser

ASKER

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.

Yes okcuser, but the IIS-service runs under the anonymous internet user acount. Thats why i proposed that.
Avatar of okcuser

ASKER

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?  
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of okcuser

ASKER

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!