Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I've uninstalled and reinstalled my Office 365. The error still occurs. The code I'm running is:

Dim objWord As Object
Dim MyCounty As String
Dim MyDeed As String
Dim mySelection As Object
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
objWord.Documents.Add Template:="D:\Documents\Custom Office Templates\file_template.dotm"

I've looked at this link https://learn.microsoft.com/en-us/office/vba/Language/Reference/User-Interface-Help/activex-component-can-t-create-object-or-return-reference-to-this-object-error-4 but it's not really helping. The uninstall/reinstall should have taken care of the registry problems, the DLL objects, and anything else mentioned in the article.

What am I missing?

The debugger points to the line Set objWord = CreateObject("Word.Application") for the source of the error. I'm guessing this means that the script can't create the Word object, but I don't know why the script is doing that or how to fix it. – Rick Colgan Jan 10, 2020 at 14:31

Check that you have the Microsoft Excel Object Library and the Microsoft Office Object Library ticked in Tools > References and that they have been registered.

If they are ticked, you may need to run Detect and Repair from the Excel Help menu to make sure that the Office installation hasn't corrupted in any way.

thanks for the effort, but its still nojoy. Both references are selected/registered and I did a complete reinstall of Office 365 last night. Still no progress. – Rick Colgan Jan 11, 2020 at 5:58 It took some time, but I determined that CyLance was blocking the script from running. Made some changes to the CyLance configuration and everything works great! – Rick Colgan Jun 7, 2020 at 16:03

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.