0

I am trying to convert Word file(s) to PDF. I have found a code that is using ComObject Word.Application. However, running the command: $word = New-Object -ComObject word.application returns the following error:

`New-Object : Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)). At line:1 char:9

  • $word = New-Object -ComObject word.application
  •     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : ResourceUnavailable: (:) [New-Object], COMException
    • FullyQualifiedErrorId : NoCOMClassIdentified,Microsoft.PowerShell.Commands.NewObjectCommand`

I have MS Word installed and running fine. I have found that my PowerShell is running 64-bit version but my Office installed as 32-bit. This may be an issue but I cannot control it as the script will be powered by 3rd party application that I have no control over and Office is installed on many computers that I really do not control also. Can I somehow register that Class? Can I do the conversion without any 3rd party software (like Word or LibreOffice) installed? Any other suggestions?

Thanks

Need to create a PDF file

2
  • Does this answer help? stackoverflow.com/a/16537996/1054225 Commented Dec 28, 2022 at 21:30
  • I would make sure you’re not running as admin, because if word is already open unelevated, you can’t instantiate in an elevated prompt. Commented Dec 28, 2022 at 21:53

1 Answer 1

0

I was not running as Admin.

However, I noticed that the same script was running fine on my other computer and everything seems the same on both of them. So, I have done the "repair" of the Office installation and that has fixed the issue.

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.