Program with Excel workbook
Hello
I have a little problem with a small application that uses an excel workbook, and i don't know what's the best way to handle this.
In the past every computers here in the company had the same culture and the same office version/language.
Now the company bought some new machines, that came with english version of the office (en-US). Now the program doesn't work, throwing the exception related with the assembly of the office.
I have two solutions to solve this, install the mui in all the computers, or the one that i want, adapt the application to work independent of the culture in the client machine.
So how to accomplish this? Set the application culture to the same culture in the computer (i think this will not work, because the excel assembly that i ship with the application isn't the correct one for the client language it's the assembly of my machine language)... One copy for each language, once again it's not possible...
Thanks
Re: Program with Excel workbook
Maybe with late binding and version checking. Here's a link to find what version is being used.
http://www.vbforums.com/showthread.php?t=402020
This may be relevant:
http://social.msdn.microsoft.com/For...6-62de43e7b238
Re: Program with Excel workbook
Thanks for the reply, but the problem isn't the version, it's the culture! :)
Re: Program with Excel workbook
Re: Program with Excel workbook
Thanks for the link but already read that... :)
Re: Program with Excel workbook
Quote:
Originally Posted by
mickey_pt
Thanks for the link but already read that... :)
So that is not an option?
How about http://www.dotnetmonster.com/Uwe/For...glish-Standard
Bypassing PIAs
Code:
Try
Dim objXlType As Type
Dim objXlObj As Object
Dim objXlWbks As Object
Dim objXlNewWbk As Object
objXlType = Type.GetTypeFromProgID("Excel.Application")
objXlObj = Activator.CreateInstance(objXlType)
objXlWbks = objXlObj.GetType.InvokeMember("Workbooks", _
System.Reflection.BindingFlags.GetProperty, _
Nothing, objXlObj, Nothing, _
New System.Globalization.CultureInfo(1033))
objXlNewWbk = objXlWbks.GetType.InvokeMember("Add", _
System.Reflection.BindingFlags.InvokeMethod, _
Nothing, objXlWbks, Nothing, _
New System.Globalization.CultureInfo(1033))
Dim visibool(0) As Object
visibool(0) = True
objXlObj.GetType.InvokeMember("Visible", _
System.Reflection.BindingFlags.SetProperty, _
Nothing, objXlObj, visibool, _
New System.Globalization.CultureInfo(1033))
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
You need to edit the culture
Re: Program with Excel workbook
Yes it's an option... in fact i wrote that, but i don't like that option, the need to install the MUI in all new computers, when updating the old ones to the new office, once again install the MUI... And they're a lot of computers :)
So i'm trying to figure out one way to adapt my code to run without installing extra content to the users, the code that you wrote it's something that i'm reading right now... MSDN
I need to make some tests to answer some questions before i look to reflection...
Thank you