Solved

ActiveX component can't create object

Posted on 2002-06-11
17
7,108 Views
Last Modified: 2013-11-25
I have visual basic program that calls to excel and save if html format a xls file.

When I execute it inside on cgi (with iis) gives the error "Error: 429 ActiveX component can't create object"
when execute the instruction 'Set objExcel = CreateObject("excel.application")' .... but the same procedure works if I execute it
in the environment of development of visual basic.

Why?

This is the code:

    Dim objExcel As Excel.Application
    Dim objBook  As Excel.Workbook
   
    Set objExcel = CreateObject("excel.application")
    objExcel.Visible = False
    Set objBook = objExcel.Workbooks.Open(FitxerOrigen)
    objBook.SaveAs FileName:=FitxerDesti, FileFormat:=xlHtml, ReadOnlyRecommended:=False, CreateBackup:=False
    objBook.Close False
    objExcel.Quit
0
Comment
Question by:arapahoe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +5
17 Comments
 
LVL 5

Expert Comment

by:Julian_K
ID: 7069858
Hi.
Try to declare the objects like:
Dim objExcel as Object
Dim objBook as Object

0
 
LVL 44

Expert Comment

by:bruintje
ID: 7070032
Hi arapahoe,

what happens is this
-in your dev environment you placed a reference to the excel object under references
-and you called the object with early binding

Dim objExcel As Excel.Application

-works great if you know which version of excel is installed on the client

but to be sure it runs on every installation of excel you use late binding

-remove the reference in your project
-then declare the excel object like Julian_K said

Dim objExcel as Object

-now call it as you used in the first place

sub tryagain()

  Dim objExcel As Object
  Set objExcel = CreateObject("excel.application")
  objExcel.Visible = False
  objExcel.Workbooks.Open(FitxerOrigen)
  objExcel.Workbooks(1).SaveAs FileName:=FitxerDesti, FileFormat:=xlHtml, ReadOnlyRecommended:=False, CreateBackup:=False
  objExcel.Workbooks(1).Close False
  objExcel.Quit
  Set objExcel = nothing
end sub

HAGD:O)Bruintje
0
 
LVL 5

Expert Comment

by:rpai
ID: 7070044
Try using the NEW keyword


   Dim objExcel As Excel.Application
   Dim objBook  As Excel.Workbook
   
   Set objExcel = New Excel.application
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 6

Expert Comment

by:simonbennett
ID: 7070121
Agree with above, however

...also check your event logs for permission errors. It is unlikely that by default you can create an instance of excel as the web user i.e.

In dev, you are logged on as "domain/your user" and probably have the correct rights to the exe file.

In IIS, you are probably running as IUSR_<MACHINENAME> which shouldn't have rights to the exe.

Also don't forget that excel *must* be registered on the webserver in order to do a createobject - you will not be able to instantiate it over a network without regisrty entries on the calling machine.

Finally beware that this is a dangerous thing to do on a public site! It is possible to run code within the spreadsheet and someone who knows what they are doing could use that to start problems!

Hope this helps

Simon
0
 

Author Comment

by:arapahoe
ID: 7070708
Simonbennett....how register the app Excel on the webserver?

My app works in a very controled envinronment.

0
 
LVL 44

Expert Comment

by:bruintje
ID: 7070765
you got to install it to use it
0
 

Author Comment

by:arapahoe
ID: 7070782
The Office is installed.

When run my program into de Visual Basic Environment works fine. But when this program runs inside IIS one error appears :-((((
0
 

Author Comment

by:arapahoe
ID: 7070786
The Office is installed.

When run my program into de Visual Basic Environment works fine. But when this program runs inside IIS one error appears :-((((
0
 
LVL 6

Expert Comment

by:simonbennett
ID: 7070882
Have you checked the permissions on the directory that conatains excel.exe (see my previous post)?
0
 

Author Comment

by:arapahoe
ID: 7070899
where? in the iis configuration? the folder when resides this app have the "Scripts and Executables" right.

in other place?
0
 
LVL 5

Expert Comment

by:rpai
ID: 7070922
Did you try instanciating the Excel Application using the NEW keyword?
0
 
LVL 6

Expert Comment

by:simonbennett
ID: 7071330
The permissions need to be set on the directory level, so open explorer, navigate to the directory with excel.exe in it, right click and select "Security". Make sure the account under which the web site runs (in IIS, directory security then anonymous access unless your users are loggin on to the domain using LDAP or something) - usually IUSR_<MachineName> - and assign read/write/execute permissions.

If your site runs under a different account you can quickly check by logging on as that account and run this scipt (saved as a .vbs) to see if you can create the object


Dim objExcel
on error resume next
Set objExcel = CreateObject("Excel.Application")
If Err <> 0 Then
  msgbox "Failed with " & err.description
Else
  msgbox "Created ok!"
End If

Set objExcel = Nothing

..if that fails check the event log (specifically application and security) for clues. Any errors let us know.

Keep trying - the answer is near!

Simon
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7071443
hearing...
0
 

Author Comment

by:arapahoe
ID: 7072099
The same error occurs. In the event viewer appears:

Event Viewer (Application)
--------------------------

Event Type:     Warning
Event Source:     MsiInstaller
Event Category:     None
Event ID:     1004
Date:          12/06/2002
Time:          08:35:57
User:          N/A
Computer:     S0600-1
Description:
Detection of product '{00000C0A-78E1-11D2-B60F-006097C998E7}', feature 'ExcelUserData', component '{8ADD2C96-C8B7-11D1-9C67-0000F81F1B38}' failed

Event Type:     Warning
Event Source:     MsiInstaller
Event Category:     None
Event ID:     1004
Date:          12/06/2002
Time:          08:35:57
User:          N/A
Computer:     S0600-1
Description:
Detection of product '{00000C0A-78E1-11D2-B60F-006097C998E7}', feature 'OfficeUserData', component '{C9AF9050-C8BE-11D1-9C67-0000F81F1B38}' failed

Event Viewer (System)
---------------------

Event Type:     Error
Event Source:     DCOM
Event Category:     None
Event ID:     10010
Date:          12/06/2002
Time:          08:36:27
User:          DOM0625\Administrador
Computer:     S0600-1
Description:
The server {00024500-0000-0000-C000-000000000046} did not register with DCOM within the required timeout.

0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7072889
Just some thoughts:
DCOM is installed properly?
IIS "knows" that Excel is installed?
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7899949
Hi arapahoe,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Refund points and save as a 0-pt PAQ.

arapahoe, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
==========
DanRollins -- EE database cleanup volunteer
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 7978267
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question