Hi Folks, I'm getting C R A Z Y with this Excel/Powershell Stuff...
MY display language is EN
My input language is fr_CH
the following code :
function Invoke([object]$m, [string]$method, $parameters) { $m.PSBase.GetType().InvokeMember( $method, [Reflection.BindingFlags]::InvokeMethod, $null, $m, $parameters,$ciUS) } $ciUS = [System.Globalization.CultureInfo]'fr-CH' $objExcel = New-object -com Excel.Application $objExcel.visible = $True $ci = [System.Globalization.CultureInfo]'fr-CH' $objWorkbook = Invoke $objExcel.Workbooks Add $objWorksheet = $objWorkbook.Worksheets.Item(1) $objWorksheet.Cells.Item(1,1).FormulaLocal = "A value in cell A1." Invoke $objWorkbook SaveAs "C:ScriptsTest.xls" > $null Invoke $objWorkbook Close 0 > $null $objExcel.Quit()
throw me the error :
Exception calling "InvokeMember" with "6" argument(s): "Object does not match target type."At line:3 char:1
+ $m.PSBase.GetType().InvokeMember(
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : TargetException
You cannot call a method on a null-valued expression.
At line:11 char:1
+ $objWorksheet = $objWorkbook.Worksheets.Item(1)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Basically this happend when you have english Excel with non english locale.
My OS is in english but my Keyboard is in French-Swiss.
Please help me I'm getting crazy...
MCITP Enterprise Administrator / Server Administrator