Use -ComObject Word.application without install Word

和自甴很熟 提交于 2021-01-28 12:38:45

问题


I have a powershell script which use "-ComObject Word.Application". I would like to use this in a windows server but it doesn't have Word. For now, when i execute , i have this error.

New-Object : La récupération de la fabrique de classes COM pour le composant avec le CLSID 
{00000000-0000-0000-0000-000000000000} a échoué en raison de l'erreur 
suivante: 80040154 Classe non enregistrée
(Exception de HRESULT : 0x80040154 (REGDB_E_CLASSNOTREG)).
Au caractère E:\BELAIRREC\Scripts\PowerShell\Doc2PDF.ps1:27 : 16
+     $Wrd     = New-Object -ComObject Word.Application
+                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ResourceUnavailable: (:) [New-Object], 
COMException
+ FullyQualifiedErrorId : 
NoCOMClassIdentified,Microsoft.PowerShell.Commands.NewObjectCommand

I think it's no doubt because Word is not installed. Is there a way to use -ComObject Word.Application without install Word ?

Thanks


回答1:


Depending on what you want to do, you might want to look at the OpenXML SDK, which is a free library from Microsoft that lets you manipulate Office documents without installing the Office products (though the SDK needs to be installed). The Open-XML-PowerTools is an open source collection of cmdlets that make working with the SDK easier.




回答2:


Any COM object you call must be installed on the computer.

There is a free Word viewer that you can download from Microsoft but I do not know if it has an exposed COM interface.



来源:https://stackoverflow.com/questions/50646343/use-comobject-word-application-without-install-word

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!