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
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 ???
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Angeljo
J'ai trouvé la cause du problème dans MSDN. Pour ceux que cela interesse, je le poste :
CAUSE You receive this error calling an Excel method when the following are true: a.. The method requires an LCID (locale identifier). b.. You run an English version of Excel but the regional settings for the computer are configured for a non-English language. If the client computer runs the English version of Microsoft Excel and the locale for the current user is configured for a language other than English, Excel will try to locate the language pack for the configured language. If the language pack is not found, the error is reported. WORKAROUND To work around this problem, you can: a.. Install the Multilingual User Interface Pack for your version of Office. b.. Or, execute the Excel method or property using InvokeMember so that you can specify the CultureInfo for the call. For example, the following code illustrates how you can invoke the Workbooks object Add method with "en-US" as the CultureInfo: Dim oApp As New Excel.Application() oApp.Visible = True oApp.UserControl = True Dim oBooks As Object = oApp.Workbooks Dim ci As System.Globalization.CultureInfo = New System.Globalization.CultureInfo("en-US") oBooks.GetType().InvokeMember("Add", Reflection.BindingFlags.InvokeMethod, Nothing, oBooks, Nothing, ci) c.. Or, set the CultureInfo prior to calling the Excel method. For example: Dim oApp As New Excel.Application() oApp.Visible = True oApp.UserControl = True Dim oldCI As System.Globalization.CultureInfo = _ System.Threading.Thread.CurrentThread.CurrentCulture System.Threading.Thread.CurrentThread.CurrentCulture = _ New System.Globalization.CultureInfo("en-US") oApp.Workbooks.Add() System.Threading.Thread.CurrentThread.CurrentCulture = oldCI-----------------------------------------------------------------------------------------------------------------------------------------------------
"Angeljo" wrote in message news:%
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
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
J'ai trouvé la cause du problème dans MSDN. Pour ceux que cela interesse, je
le poste :
CAUSE
You receive this error calling an Excel method when the following are true:
a.. The method requires an LCID (locale identifier).
b.. You run an English version of Excel but the regional settings for the
computer are configured for a non-English language.
If the client computer runs the English version of Microsoft Excel and the
locale for the current user is configured for a language other than English,
Excel will try to locate the language pack for the configured language. If
the language pack is not found, the error is reported.
WORKAROUND
To work around this problem, you can:
a.. Install the Multilingual User Interface Pack for your version of
Office.
b.. Or, execute the Excel method or property using InvokeMember so that
you can specify the CultureInfo for the call. For example, the following
code illustrates how you can invoke the Workbooks object Add method with
"en-US" as the CultureInfo:
Dim oApp As New Excel.Application()
oApp.Visible = True
oApp.UserControl = True
Dim oBooks As Object = oApp.Workbooks
Dim ci As System.Globalization.CultureInfo = New
System.Globalization.CultureInfo("en-US")
oBooks.GetType().InvokeMember("Add", Reflection.BindingFlags.InvokeMethod,
Nothing, oBooks, Nothing, ci)
c.. Or, set the CultureInfo prior to calling the Excel method. For example:
Dim oApp As New Excel.Application()
oApp.Visible = True
oApp.UserControl = True
Dim oldCI As System.Globalization.CultureInfo = _
System.Threading.Thread.CurrentThread.CurrentCulture
System.Threading.Thread.CurrentThread.CurrentCulture = _
New System.Globalization.CultureInfo("en-US")
oApp.Workbooks.Add()
System.Threading.Thread.CurrentThread.CurrentCulture =
oldCI-----------------------------------------------------------------------------------------------------------------------------------------------------
"Angeljo" <angeljo999@hotmail.com> wrote in message
news:%23zjhEMVkGHA.4512@TK2MSFTNGP04.phx.gbl...
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
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 ???
J'ai trouvé la cause du problème dans MSDN. Pour ceux que cela interesse, je le poste :
CAUSE You receive this error calling an Excel method when the following are true: a.. The method requires an LCID (locale identifier). b.. You run an English version of Excel but the regional settings for the computer are configured for a non-English language. If the client computer runs the English version of Microsoft Excel and the locale for the current user is configured for a language other than English, Excel will try to locate the language pack for the configured language. If the language pack is not found, the error is reported. WORKAROUND To work around this problem, you can: a.. Install the Multilingual User Interface Pack for your version of Office. b.. Or, execute the Excel method or property using InvokeMember so that you can specify the CultureInfo for the call. For example, the following code illustrates how you can invoke the Workbooks object Add method with "en-US" as the CultureInfo: Dim oApp As New Excel.Application() oApp.Visible = True oApp.UserControl = True Dim oBooks As Object = oApp.Workbooks Dim ci As System.Globalization.CultureInfo = New System.Globalization.CultureInfo("en-US") oBooks.GetType().InvokeMember("Add", Reflection.BindingFlags.InvokeMethod, Nothing, oBooks, Nothing, ci) c.. Or, set the CultureInfo prior to calling the Excel method. For example: Dim oApp As New Excel.Application() oApp.Visible = True oApp.UserControl = True Dim oldCI As System.Globalization.CultureInfo = _ System.Threading.Thread.CurrentThread.CurrentCulture System.Threading.Thread.CurrentThread.CurrentCulture = _ New System.Globalization.CultureInfo("en-US") oApp.Workbooks.Add() System.Threading.Thread.CurrentThread.CurrentCulture = oldCI-----------------------------------------------------------------------------------------------------------------------------------------------------
"Angeljo" wrote in message news:%
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
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
Christophe
Salut,
(Je voudrai juste te donner un petit tips)
Je te conseille pour piloter des applications Office d'utiliser les office Pias (traduction des objets COM de Office pour dotnet).
Sinon, je te conseille le composant Excel de ComponentOne qui marche sans office et est plus rapide, mais payant....
Angeljo a écrit :
J'ai trouvé la cause du problème dans MSDN. Pour ceux que cela interesse, je le poste :
CAUSE You receive this error calling an Excel method when the following are true: a.. The method requires an LCID (locale identifier). b.. You run an English version of Excel but the regional settings for the computer are configured for a non-English language. If the client computer runs the English version of Microsoft Excel and the locale for the current user is configured for a language other than English, Excel will try to locate the language pack for the configured language. If the language pack is not found, the error is reported. WORKAROUND To work around this problem, you can: a.. Install the Multilingual User Interface Pack for your version of Office. b.. Or, execute the Excel method or property using InvokeMember so that you can specify the CultureInfo for the call. For example, the following code illustrates how you can invoke the Workbooks object Add method with "en-US" as the CultureInfo: Dim oApp As New Excel.Application() oApp.Visible = True oApp.UserControl = True Dim oBooks As Object = oApp.Workbooks Dim ci As System.Globalization.CultureInfo = New System.Globalization.CultureInfo("en-US") oBooks.GetType().InvokeMember("Add", Reflection.BindingFlags.InvokeMethod, Nothing, oBooks, Nothing, ci) c.. Or, set the CultureInfo prior to calling the Excel method. For example: Dim oApp As New Excel.Application() oApp.Visible = True oApp.UserControl = True Dim oldCI As System.Globalization.CultureInfo = _ System.Threading.Thread.CurrentThread.CurrentCulture System.Threading.Thread.CurrentThread.CurrentCulture = _ New System.Globalization.CultureInfo("en-US") oApp.Workbooks.Add() System.Threading.Thread.CurrentThread.CurrentCulture = oldCI-----------------------------------------------------------------------------------------------------------------------------------------------------
"Angeljo" wrote in message news:%
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
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
Salut,
(Je voudrai juste te donner un petit tips)
Je te conseille pour piloter des applications Office d'utiliser les
office Pias (traduction des objets COM de Office pour dotnet).
Sinon, je te conseille le composant Excel de ComponentOne qui marche
sans office et est plus rapide, mais payant....
Angeljo a écrit :
J'ai trouvé la cause du problème dans MSDN. Pour ceux que cela interesse, je
le poste :
CAUSE
You receive this error calling an Excel method when the following are true:
a.. The method requires an LCID (locale identifier).
b.. You run an English version of Excel but the regional settings for the
computer are configured for a non-English language.
If the client computer runs the English version of Microsoft Excel and the
locale for the current user is configured for a language other than English,
Excel will try to locate the language pack for the configured language. If
the language pack is not found, the error is reported.
WORKAROUND
To work around this problem, you can:
a.. Install the Multilingual User Interface Pack for your version of
Office.
b.. Or, execute the Excel method or property using InvokeMember so that
you can specify the CultureInfo for the call. For example, the following
code illustrates how you can invoke the Workbooks object Add method with
"en-US" as the CultureInfo:
Dim oApp As New Excel.Application()
oApp.Visible = True
oApp.UserControl = True
Dim oBooks As Object = oApp.Workbooks
Dim ci As System.Globalization.CultureInfo = New
System.Globalization.CultureInfo("en-US")
oBooks.GetType().InvokeMember("Add", Reflection.BindingFlags.InvokeMethod,
Nothing, oBooks, Nothing, ci)
c.. Or, set the CultureInfo prior to calling the Excel method. For example:
Dim oApp As New Excel.Application()
oApp.Visible = True
oApp.UserControl = True
Dim oldCI As System.Globalization.CultureInfo = _
System.Threading.Thread.CurrentThread.CurrentCulture
System.Threading.Thread.CurrentThread.CurrentCulture = _
New System.Globalization.CultureInfo("en-US")
oApp.Workbooks.Add()
System.Threading.Thread.CurrentThread.CurrentCulture =
oldCI-----------------------------------------------------------------------------------------------------------------------------------------------------
"Angeljo" <angeljo999@hotmail.com> wrote in message
news:%23zjhEMVkGHA.4512@TK2MSFTNGP04.phx.gbl...
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
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 ???
Sinon, je te conseille le composant Excel de ComponentOne qui marche sans office et est plus rapide, mais payant....
Angeljo a écrit :
J'ai trouvé la cause du problème dans MSDN. Pour ceux que cela interesse, je le poste :
CAUSE You receive this error calling an Excel method when the following are true: a.. The method requires an LCID (locale identifier). b.. You run an English version of Excel but the regional settings for the computer are configured for a non-English language. If the client computer runs the English version of Microsoft Excel and the locale for the current user is configured for a language other than English, Excel will try to locate the language pack for the configured language. If the language pack is not found, the error is reported. WORKAROUND To work around this problem, you can: a.. Install the Multilingual User Interface Pack for your version of Office. b.. Or, execute the Excel method or property using InvokeMember so that you can specify the CultureInfo for the call. For example, the following code illustrates how you can invoke the Workbooks object Add method with "en-US" as the CultureInfo: Dim oApp As New Excel.Application() oApp.Visible = True oApp.UserControl = True Dim oBooks As Object = oApp.Workbooks Dim ci As System.Globalization.CultureInfo = New System.Globalization.CultureInfo("en-US") oBooks.GetType().InvokeMember("Add", Reflection.BindingFlags.InvokeMethod, Nothing, oBooks, Nothing, ci) c.. Or, set the CultureInfo prior to calling the Excel method. For example: Dim oApp As New Excel.Application() oApp.Visible = True oApp.UserControl = True Dim oldCI As System.Globalization.CultureInfo = _ System.Threading.Thread.CurrentThread.CurrentCulture System.Threading.Thread.CurrentThread.CurrentCulture = _ New System.Globalization.CultureInfo("en-US") oApp.Workbooks.Add() System.Threading.Thread.CurrentThread.CurrentCulture = oldCI-----------------------------------------------------------------------------------------------------------------------------------------------------
"Angeljo" wrote in message news:%
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
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 ???