Solved

ActiveX component can't create object

Posted on 2002-06-11
17
7,039 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
  • 5
  • 3
  • 2
  • +5
17 Comments
 
LVL 5

Expert Comment

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

0
 
LVL 44

Expert Comment

by:bruintje
Comment Utility
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
Comment Utility
Try using the NEW keyword


   Dim objExcel As Excel.Application
   Dim objBook  As Excel.Workbook
   
   Set objExcel = New Excel.application
0
 
LVL 6

Expert Comment

by:simonbennett
Comment Utility
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
Comment Utility
Simonbennett....how register the app Excel on the webserver?

My app works in a very controled envinronment.

0
 
LVL 44

Expert Comment

by:bruintje
Comment Utility
you got to install it to use it
0
 

Author Comment

by:arapahoe
Comment Utility
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
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 6

Expert Comment

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

Author Comment

by:arapahoe
Comment Utility
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
Comment Utility
Did you try instanciating the Excel Application using the NEW keyword?
0
 
LVL 6

Expert Comment

by:simonbennett
Comment Utility
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
Comment Utility
hearing...
0
 

Author Comment

by:arapahoe
Comment Utility
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
Comment Utility
Just some thoughts:
DCOM is installed properly?
IIS "knows" that Excel is installed?
0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
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
Comment Utility
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now