Create Excel Object Problem

  • Thread starter Thread starter Marisha
  • Start date Start date
M

Marisha

Hi Guys,

I have some problem,

I'm trying to create excel object ( vb.net web application using Share
Point.)
Using:
excel_app = New Excel.Application
or
excel_app = CreateObject("Excel.Application")

The weird thing that sometimes it works,sometimes it fails with
error:"Cannot create ActiveX Component" ,only after rebooting the
machine it works form a while?

Does someone know what can be wrong?

Thanks a lot,

Marina
 
Hi,

Make sure you are using the Primary Interop Assemblies for excel:

<http://msdn.microsoft.com/library/d.../html/wrrefofficeprimaryinteropassemblies.asp>

Then, instead of using Excel.Application, use the fully qualified name through
the interop assembly: Microsoft.Office.Interop.Excel.ApplicationClass

Hope this helps.

Best regards,

Rodger

Sequence Diagram Editor - Draw sequence diagrams faster
<http://www.SequenceDiagramEditor.com>

Time Management Guide - Make better use of your time
<http://www.TimeThoughts.com>
 
Hi Rodger,

Unfortunately even after using
Microsoft.Office.Interop.Excel­.ApplicationClass

it gives me randomly the same error.
Sometimes it works in run time,sometime during debugging it fails to
create an object.
I'm using this code:

Dim excel_app As Microsoft.Office.Interop.Excel.ApplicationClass

Try
excel_app = New
Microsoft.Office.Interop.Excel.ApplicationClass
excel_app = CreateObject("Excel.Application")
Catch
.....
What can be a problem?
Any Ideas?

Thanks,
Marina
 
Hi,

It could be the second line, I don't think you need it:

excel_app = CreateObject("Excel.Application")

Try just doing
excel_app = New Microsoft.Office.Interop.Excel.ApplicationClass

and using excel_app directly.

Best regards,

Rodger

Sequence Diagram Editor - Draw sequence diagrams faster
<http://www.SequenceDiagramEditor.com>
 
Hi Again,

I tried using your advice, it worked for a while,now it refuses....
May be something wrong with the settings?

Thanks,

Marina
 
Back
Top