Hi!,
I have received the next error message when I executed a Powershell v3.0 script withMS Excel 2010:
Exception calling "InvokeMember" with "6" argument(s): "Object does not match target type."
At D:\My Scripting Code & Querys\Test.ps1:5 char:1
+ $xlbooks.PSBase.GetType().InvokeMember("Add", [Reflection.BindingFlags]::InvokeM ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : TargetException
The script is the next:
$xl = New-Object -comobject "excel.application" $xl.visible = $true $xlbooks =$xl.workbooks $newci = [System.Globalization.CultureInfo]'en-US' $xlbooks.PSBase.GetType().InvokeMember("Add", [Reflection.BindingFlags]::InvokeMethod, $null, $xlbooks, $null, $newci)
My locale is en-US but my keyboard is Latinamerican
G.