[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 7159
  • Last Modified:

ActiveX component can't create object

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
arapahoe
Asked:
arapahoe
  • 5
  • 3
  • 2
  • +5
1 Solution
 
Julian_KCommented:
Hi.
Try to declare the objects like:
Dim objExcel as Object
Dim objBook as Object

0
 
bruintjeCommented:
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
 
rpaiCommented:
Try using the NEW keyword


   Dim objExcel As Excel.Application
   Dim objBook  As Excel.Workbook
   
   Set objExcel = New Excel.application
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
simonbennettCommented:
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
 
arapahoeAuthor Commented:
Simonbennett....how register the app Excel on the webserver?

My app works in a very controled envinronment.

0
 
bruintjeCommented:
you got to install it to use it
0
 
arapahoeAuthor Commented:
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
 
arapahoeAuthor Commented:
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
 
simonbennettCommented:
Have you checked the permissions on the directory that conatains excel.exe (see my previous post)?
0
 
arapahoeAuthor Commented:
where? in the iis configuration? the folder when resides this app have the "Scripts and Executables" right.

in other place?
0
 
rpaiCommented:
Did you try instanciating the Excel Application using the NEW keyword?
0
 
simonbennettCommented:
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
 
Richie_SimonettiIT OperationsCommented:
hearing...
0
 
arapahoeAuthor Commented:
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
 
Richie_SimonettiIT OperationsCommented:
Just some thoughts:
DCOM is installed properly?
IIS "knows" that Excel is installed?
0
 
DanRollinsCommented:
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
 
SpideyModCommented:
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 5
  • 3
  • 2
  • +5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now