Code gives an error of activex

fraufreda

Board Regular
Joined
Oct 14, 2010
Messages
190
hi.
Yesterday the code was working without any bugs. but today i tried it in two machines and it gives me the same error although i haven't change anything in the code. I even restarted my pc but without any success. it give error 429 Activex component can't create an object.

any help would be appreciated

Code:
Dim doc As Object, sel As Object
    Dim oWord As Object, oDoc As Object, wRng As Object
    Dim MyPath As String
    Dim file
    Dim ws As Worksheet

    '~~> Establish an EXCEL application object
    'On Error Resume Next
    Set oWord = GetObject(, "Word.Application")
    
    MyPath = "F:\Users\Desktop\My files\"
    file = Dir(MyPath & "*.rtf")

    '~~> Open the Attachement
    Do While file <> ""
    Set oDoc = oWord.Documents.Open(Filename:=MyPath & file, ConfirmConversions:=False, _
        ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
        PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
        WritePasswordTemplate:="", Format:=0, XMLTransform:="", _
        Encoding:=1200)

    '~~> Get the comeplete text and copy it
    Set wRng = oDoc.Range
    wRng.Copy

    '~~> Close word Doc
    oDoc.Close
    'paste
        'For Each ws In ThisWorkbook.Sheets
            Set ws = ThisWorkbook.Sheets.Add
            ActiveSheet.Cells(1, 1).Select
            ActiveSheet.PasteSpecial Format:="Text", Link:=False, DisplayAsIcon:=False
            file = Dir()
        'Next
        
    Loop
    '~~> Clean up
    Set wRng = Nothing: Set oDoc = Nothing: Set oWord = Nothing
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
I suspect it won't work unless MS Word is running already. GetObject gets a current instance. CreateObject would create a new one.

WBD
 
Upvote 0
thank you for your reply
it is back to work now. I just put the code into a new workbook.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,380
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top