Piloter Excel depuis VB.NET

Office

Piloter Excel depuis VB.NET


Anonymous 06-16-2006, 17:07
Dans mon app (VB.net en Visual Studio2003), je dois ouvrir Excel puis
transposer des datas depuis mon app vers Excel. En VB6 j'y arrivais sans pb
mais en .net... j'arrive à ouvrir Excel mais pas un fichier.
J'ai Excel 2003 installé sur ma machine (Windows XP SP2)
J'ai donc mis les références : Microsoft Excel 11.0 Object Library et
Microsoft Office 11.0 Object Library

Voilà le code :
-------------------------------------------------------------------------------
Private Sub uButExcelFile_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles uButExcelFile.Click

Dim oXL As New Microsoft.Office.Interop.Excel.Application
Dim oBook As Microsoft.Office.Interop.Excel.Workbook
Try

oXL.Visible = True
oBook =
oXL.Workbooks.Open("C:\_DEVINTERNE\CoilInteg\Prg\Guy\Loon\Loon\Templates\loonNet.xls")

Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.ToString)
If Not oXL Is Nothing Then
oXL.Quit()
oXL = Nothing
ReleaseComObject(oXL)
End If
End Try

End Sub
-------------------------------------------------------------------------------------------
Chaque fois que je fais tourner, j'ouvre Excel, il devient visible mais dès
qu'il arrive à la ligne oBook = oXl.workbooks.open(...) il lève une
exception :
"System.Runtime.InteropServices.ComException (0x80028018) : old format or
invalid type library at Microsoft.office.Interop.excel.Workgroups.open(...)"
Or je suis sûre d'avoir Excel 2003 (donc la library 11.0. Que manque-t-il ou
qu'est ce qui est faux dans le code ???

Merci de votre aide.

Angeljo

Re : Piloter Excel depuis VB.NET


Anonymous 07-03-2006, 12:01
Il m'arrive exactement le même problème. Alors si, depuis, quelqu'un a trouvé une solution, pourrait-il la poster?

Merci bien.

Re : Piloter Excel depuis VB.NET


Anonymous 07-25-2006, 10:52
La réponse se trouve surement a cette addresse http://support.microsoft.com/kb/320369/en-us. Du moins ca a permis de resoudre mon probleme qui semble etre identique au tiens.

Re : Piloter Excel depuis VB.NET


Anonymous 10-17-2006, 16:35

salut salut,

 

lis ceci :

 

'http://support.microsoft.com/kb/320369

 

ca devrait resoudre ton probleme

ciao ciao

christophe

un bouillonnais

 Anonymous wrote:
Dans mon app (VB.net en Visual Studio2003), je dois ouvrir Excel puis transposer des datas depuis mon app vers Excel. En VB6 j'y arrivais sans pb mais en .net... j'arrive à ouvrir Excel mais pas un fichier. J'ai Excel 2003 installé sur ma machine (Windows XP SP2) J'ai donc mis les références : Microsoft Excel 11.0 Object Library et Microsoft Office 11.0 Object Library Voilà le code : ------------------------------------------------------------------------------- Private Sub uButExcelFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles uButExcelFile.Click Dim oXL As New Microsoft.Office.Interop.Excel.Application Dim oBook As Microsoft.Office.Interop.Excel.Workbook Try oXL.Visible = True oBook = oXL.Workbooks.Open("C:\_DEVINTERNE\CoilInteg\Prg\Guy\Loon\Loon\Templates\loonNet.xls") Catch ex As Exception System.Windows.Forms.MessageBox.Show(ex.ToString) If Not oXL Is Nothing Then oXL.Quit() oXL = Nothing ReleaseComObject(oXL) End If End Try End Sub ------------------------------------------------------------------------------------------- Chaque fois que je fais tourner, j'ouvre Excel, il devient visible mais dès qu'il arrive à la ligne oBook = oXl.workbooks.open(...) il lève une exception : "System.Runtime.InteropServices.ComException (0x80028018) : old format or invalid type library at Microsoft.office.Interop.excel.Workgroups.open(...)" Or je suis sûre d'avoir Excel 2003 (donc la library 11.0. Que manque-t-il ou qu'est ce qui est faux dans le code ??? Merci de votre aide. Angeljo

Sponsorisé par Community Server


Conditions d’utilisation et Copyright
Respect de la vie privée