Runtime Error "429": ActiveX component cannot create VBA object

I try to save Word documents using Excel VBA, but I get the error message "ActiveX component cannot create the object."

When debugging, an error occurs from the line: Set wrdApps = CreateObject("Word.Application") . It worked fine, but then he just started giving me this error. Does anyone know how to fix this? Thanks for the help!

 Sub saveDoc() Dim i As Integer For i = 1 To 2661: Dim fname As String Dim fpath As String With Application .DisplayAlerts = False .ScreenUpdating = False .EnableEvents = False End With fname = ThisWorkbook.Worksheets(3).Range("H" & i).Value fpath = ThisWorkbook.Worksheets(3).Range("G" & i).Value Dim wrdApps As Object Dim wrdDoc As Object Set wrdApps = CreateObject("Word.Application") 'the next line copies the active document- the ActiveDocument.FullName ' is important otherwise it will just create a blank document wrdApps.documents.Add wrdDoc.FullName Set wrdDoc = wrdApps.documents.Open(ThisWorkbook.Worksheets(3).Range("f" & i).Value) ' do not need the Activate, it will be Activate wrdApps.Visible = False ' the next line saves the copy to your location and name wrdDoc.SaveAs "I:\Yun\RTEMP DOC & PDF\" & fname 'next line closes the copy leaving you with the original document wrdDoc.Close On Error GoTo NextSheet: NextSheet: Resume NextSheet2 NextSheet2: Next i With Application .DisplayAlerts = True .ScreenUpdating = True .EnableEvents = True End With End Sub 
+10
source share
6 answers

I had a problem upgrading from Windows 7 to 10 when I took along a stock of my VBA scripts. I'm still not sure what is the main cause of the error, but at the same time, this piece of code worked for me. This is a workaround that limits the need to have Word (or Outlook / Excel) already in the open (manually) state, but should allow your script to run if you have links installed. Just change "CreateObject(" to "GetObject(, " . This will tell the system to use an already open window.

The full code to use will be:

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

Is wrdDoc initialized? Are you trying to use wrdDoc before the object was installed?

 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 
+1
source

Ensure that the Microsoft Excel object library and Microsoft Office object library are marked with Tools> Links and that they are registered.

If they are checked, you may need to run Detect and Repair from the Excel Help menu to make sure that the Office installation is not damaged in any way.

+1
source

Try using 32-bit version of Microsoft Office

0
source

In my case, this is due to the presence of a second ThisWorkbook object.

Excel Workbook objects created in several Excel VBA projects

No other solution was found in this link. I have not tried it myself.

0
source

Try this .. I have come across this many times ...

so I just start my Excel by searching it (located on the taskbar), then right-clicking, then "run as administrator" or, if you have already created the Excel file, open it from the file> open> view. Avoid double-clicking on the Excel file to open it directly.

-1
source

Source: https://habr.com/ru/post/948157/


All Articles