System.Exception: Cannot create ActiveX component. at Microsoft.Vi

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Thanks

    #1

    System.Exception: Cannot create ActiveX component. at Microsoft.Vi

    I would like to output a dataset to excel from a text file but did not work.
    I alreay add the microsoft active component 2.7 and 2.8 and microsoft excel
    11 component library but no luck. Please show me the light!

    Imports System.Data
    Imports System.Data.Sql Client
    Imports System.Data.Com mon
    Imports System.IO
    Imports Microsoft.Offic e.Core
    Imports Microsoft.Offic e.Interop.Excel

    Try

    'Create a new instance of Excel.
    Dim oExcel As Object
    oExcel = CreateObject("E xcel.Applicatio n")

    'Open the text file and save it in the Excel workbook format.
    oExcel.Workbook s.OpenText(sSam pleFolder & "help.txt", _
    , , , -4142, , True) 'xlTextQualifie rNone=-4142

    oExcel.ActiveWo rkbook.SaveAs(s SampleFolder & "help.xls", _
    -4143) 'xlWorkbookNorm al = -4143

    'Quit Excel.
    oExcel.Quit()
    oExcel = Nothing
    GC.Collect()

    Catch ex As Exception
    Response.Write( ex.ToString)
    End Try
Working...