Uderc programming article aggregator sites

SharePoint PowerShell script to open Excel.Application on Windows server 2008 R2

Advertisement
Hi
I am building a PowerShell script to open an Excel file store on SharePoint document library.  Sound simple enough but I just couldn't get over an error and hopefully someone can help give an answer here.
I have found many sample codes to use.  All of the sample codes show that a new object must be created for Excel application
like ($Excel = New-Object -comobject Excel.Application) before that excel file can be read.
When I run this comand on a SharePoint server (Windows 2008 R2) either inside the script or by itself I keep getting the following error:
 New-Object : Cannot load COM type Excel.Application.
+ $excel = New-Object <<<<  -Com Excel.Application
    + CategoryInfo          : InvalidType: (:) [New-Object], PSArgumentException
For the test,  I ran this comand on a Windows 7 with MS Office applications installed,  then it ran fine.
Is that because I don't have Office application (Excel) installed on the server to run this or some services need to be turned on?
From the sample codes, look like I should be able to run it on the Server with SharePoint installed.
Thanks for any advice or solution to resolve my issue.
Swanl
Advertisement
The best answer: So I'm assuming this won't return anything either?
Get-WMIObject Win32_ClassicCOMClassSetting | ? {$_.VersionIndependentProgId -like 'excel.application'}
You need Office/Excel installed on the server because you're accessing those .DLLs for the automation functionality, but depending on what you're trying to do you may be able to use one of the office viewers:
http://www.microsoft.com/en-us/download/details.aspx?id=10 although I'm not sure how much of the com (if any) is exposed in a viewer install.  if Office is not possible due to
budget reasons, I believe there are several 3rd party providers who can produce a com object that will handle Excel formats.