title image


Smiley vb.net05: Fehler beim öffnen von einem Excel Workbook
Ich versuche gerade ein Excel Workbook mittels VB.net zu öffnen und kriege immer einen fehler.



Fehler:

COMException: Old format or invalid type library. (Exception from HRESULT: 0x80028018 (TYPE_E_INVDATAREAD))



sPath: C:\Documents and Settings\amarty\My Documents\Documents\Work\SiteDocumentation\SiteDocumentation_Sandbox.xls

Code:

Public Class ExcelTest



Shared Sub Main(ByVal sPath As String)

Dim xlsApp As Excel.Application

Dim xlsWorkbook As Excel.Workbook

Dim xlsWorksheet As Excel.Worksheet

Dim xlsRange As Excel.Range



Try



'Create objects used to manipulate excel files

xlsApp = New Excel.Application





'Open the needed excel workbook

MessageBox.Show(sPath)

xlsWorkbook = xlsApp.Workbooks.Open(sPath)

xlsApp.Visible = True

xlsWorkbook.Activate()





xlsWorksheet = xlsWorkbook.Sheets("WizardOptions")



'Write some stuff to cell A1

xlsRange = xlsWorksheet.Range("A1")

xlsRange.Value = sPath



'Close Excel workbook

xlsApp.Quit()

Catch ex As COMException

If xlsApp IsNot Nothing Then

xlsApp.Quit()

End If

VB.Net_Sandbox.frMain.txtContent.Text = "sPath: " + sPath

VB.Net_Sandbox.frMain.txtContent.Text = VB.Net_Sandbox.frMain.txtContent.Text _

+ ex.GetType().Name(+": " + ex.Message.ToString())



Catch ex As Exception

If xlsApp IsNot Nothing Then

xlsApp.Quit()

End If

VB.Net_Sandbox.frMain.txtContent.Text = ex.GetType().Name + ": " + ex.Message.ToString()

End Try



'Release memory

xlsApp = Nothing

xlsWorkbook = Nothing

xlsWorksheet = Nothing

End Sub

End Class
mfg Linuxcrash

geschrieben von

Login

E-Mail:
  

Passwort:
  

Beitrag anfügen

Symbol:
 
 
 
 
 
 
 
 
 
 
 
 
 

Überschrift: