Solved

ActiveX component can't create object

Posted on 2002-06-11
17
7,050 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
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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA Excel: fill / replace values based on a config sheet. 5 61
change vba from autofit to 13.5 width? 4 28
Saving history changes to sub form 4 36
Spell Check in VB6 13 99
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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

920 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

15 Experts available now in Live!

Get 1:1 Help Now