4

I am trying to load an Excel file using PowerShell Core for Mac but I am encountering an issue with New-Object. It's failing on the very first line

$Excel = New-Object -ComObject Excel.Application

This is the error message I receive:

New-Object : A parameter cannot be found that matches parameter name
'ComObject'.
At line:1 char:21
+ $Excel = New-Object -ComObject Excel.Application
+                     ~~~~~~~~~~
     + CategoryInfo          : InvalidArgument: (:) [New-Object], ParameterBindingException
     + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

Has anyone encountered this issue and does anyone know how to fix it?

2
  • 4
    The Excel.Application COM object is only available when Excel is installed. And I'm not sure if the Mac version of MS Office even provides COM objects. You may want to consider using the ImportExcel PowerShell module instead. Commented Aug 10, 2018 at 13:41
  • 1
    There is not ComObject in Mac OSX even when Excel for Mac is installed. Commented May 7, 2019 at 15:56

1 Answer 1

4

The error message you're receiving says the -ComObject parameter is invalid. Judging from this issue posted on the powershell github I'd say -ComObject is invalid because it is not supported on the Mac platform.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.