Run-time error '429': ActiveX component can't create object VBA

為{幸葍}努か 提交于 2019-12-01 16:14:37
user64773

I had an issue when upgrading from Windows 7 to 10 when bringing my hoard of VBA scripts with me. Still not sure what the root cause of the error is, but in the mean time this piece of code worked for me. This is a workaround that limits the need to have Word (or Outlook/Excel) already in open (manually) state, but should allow your script to run if you have your references set. Just change "CreateObject(" to "GetObject(, ". This will tell the system to use an already open window.

The complete code to use would be:

Dim wrdApps As Object
Dim wrdDoc As Object
Set wrdApps = GetObject(, "Word.Application")

Is wrdDoc initialised? Are you trying to use wrdDoc before the object has been Set?

wrdApps.documents.Add wrdDoc.FullName
Set wrdDoc = wrdApps.documents.Open(ThisWorkbook.Worksheets(3).Range("f" & i).Value)

Should the first line be ActiveDocument.FullName as in the comments? So:

wrdApps.documents.Add ActiveDocument.FullName

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.

It's seems to be linked to the presence of a second "ThisWorkbook" object, in my case.

Excel VBA Project has generated multiple Workbook objects

No other solution found that the one in this link. I didn't try it myself, though.

Try this one.. i've encountered this a lot of time...

so I just run my excel by searching it (located on taskbar), then right click then "run as administrator" or if you already created the excel file, open it from file>open>browse. avoid just double clicking the excel file to open directly.

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