I have this code:

$App = New-Object -ComObject Excel.Application
$App.Name
$App.GetType()

$Application = [Runtime.InteropServices.Marshal]::CreateWrapperOfType( `
$App, [Microsoft.Office.Interop.Excel.Application])


It throws the following error:

Exception calling "CreateWrapperOfType" with "2" argument(s): "The type must
be __ComObject or be
derived from __ComObject.
Parameter name: t"
At line:5 char:70
+ $Application = [Runtime.InteropServices.Marshal]::CreateWrapperOfType <<<<
( `
+ CategoryInfo : NotSpecified: ( [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException


Why is this? Where can I find information on how PowerShell COM interop works?

Thanks in advance.



--
urkec