locked
PS C:\Users\xxx> $xl=[Runtime.InteropServices.Marshal]::GetActiveObject('Excel.Application') RRS feed

  • Question

  • throws an error:

    Exception calling "GetActiveObject" with "1" argument(s): "Operation unavailable (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE))"
    At line:1 char:1
    + $xl=[Runtime.InteropServices.Marshal]::GetActiveObject('Excel.Applica ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : COMException

    I am not able to decipher what the above error means and I need to just close excel

    Stop-Process -Name "excel"

    Then open a particular file and set it to active. The title is an intermediate code in trying to invoke excel and then open the file.

    Tuesday, November 3, 2020 10:36 PM

All replies

  • throws an error:

    Exception calling "GetActiveObject" with "1" argument(s): "Operation unavailable (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE))"
    At line:1 char:1
    + $xl=[Runtime.InteropServices.Marshal]::GetActiveObject('Excel.Applica ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : COMException

    I am not able to decipher what the above error means and I need to just close excel

    Stop-Process -Name "excel"

    Then open a particular file and set it to active. The title is an intermediate code in trying to invoke excel and then open the file.

    1 no questions in a post

    2 no code on scripting forum

    3 no description

    4 no answer?


    The opinion expressed by me is not an official position of Microsoft

    • Edited by Vector BCO Tuesday, November 3, 2020 11:51 PM
    Tuesday, November 3, 2020 11:49 PM
  • You must have a file open in Excel to use this:

    Add-Type -Assembly Microsoft.Office.Interop.Excel
    Start-Process c:\scripts\test.xlsx
    Start-Sleep 10
    $xl = [Runtime.InteropServices.Marshal]::GetActiveObject('Excel.Application')


    \_(ツ)_/

    Wednesday, November 4, 2020 12:15 AM