Cannot create ActiveX component

A

Administrator

Hi,

My web development server is a Windows 2000 SP4 system.
Had created an aspx page with the following code which I had extracted from
1 of the Microsoft websites:

Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object

'Start a new workbook in Excel.
oExcel = CreateObject("Excel.Application")
oBook = oExcel.Workbooks.Add

'Add data to cells of the first worksheet in the new workbook.
oSheet = oBook.Worksheets(1)
oSheet.Range("A1").Value = "Last Name"
oSheet.Range("B1").Value = "First Name"
oSheet.Range("A1:B1").Font.Bold = True
oSheet.Range("A2").Value = "Doe"
oSheet.Range("B2").Value = "John"

'Save the Workbook and quit Excel.
oBook.SaveAs("C:\Temp\Book1.xls")
oSheet = Nothing
oBook = Nothing
oExcel.Quit()
oExcel = Nothing
GC.Collect()

When I attempted to run & debug the aspx page, I encountered the following
error message on the statement,
oExcel = CreateObject("Excel.Application"):

System.Exception was unhandled by user code
Message="Cannot create ActiveX component."
Source="Microsoft.VisualBasic"
StackTrace:
at Microsoft.VisualBasic.Interaction.CreateObject(String ProgId,
String ServerName)
at ASP.createexcel_aspx.Button1_Click(Object sender, EventArgs e) in
C:\Inetpub\ASP\CreateExcel.aspx:line 18
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String
eventArgument)
at
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo
stBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection
postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint


I had also tried the same code on another WinXP system where there is
Microsoft Excel installed & it worked out fine.
Thinking I have to install Microsoft Excel on the Win2000 system as well,
but it gave the same error message after I had installed Microsoft Excel.
Anything I had missed out?

Thanks in advance.

Regards,
Michael.
 
M

Mark Rae

Anything I had missed out?

The first thing to realise is that server-side Office automation is highly
likely not to work... Microsoft actively discourages its use to the extent
where they won't actually give any support at all to a solution which uses
it: http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2 (see
the paragraph in bold)

The problem you are currently facing is entirely consistent with this.

Luckily, there is no need to use server-side Office automation, as several
other solutions exist depending on what you are trying to do...

What are you trying to do...?
 
A

Administrator

I'm trying to see if I can create, update & delete an excel worksheet from
an aspx page.
Any workaround?
 
M

Mark Rae

I'm trying to see if I can create, update & delete an excel worksheet from
an aspx page.
Any workaround?

1) Use HTML
Output the data as HTML, then save it with an .xls extension - Excel will
work with it just like a native workbook.

2) Use the XML file format
http://www.microsoft.com/downloads/...52-3547-420a-a412-00a2662442d9&displaylang=en
http://www.microsoft.com/downloads/...80-f2c0-4b80-9ad1-2cb0c300aef9&displaylang=en

3) Use ADO.NET
http://www.google.co.uk/search?sour...rls=GGLG,GGLG:2006-28,GGLG:en&q=ADO.NET+Excel
Once the file has been created initially, ADO.NET can update it just like
any other OleDb data source.

4) Use a 3rd-party tool
http://www.aspose.com/Products/Aspose.Cells/Default.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top