0

I have created a VBA Project in Excel that uses System_Windows_Forms.RichTextBox control.

In VBA Project Editor menu Add-Ins > References I have checked "System_Windows_Forms" reference.

(The path of the reference is C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Windows.Forms.tlb)

This is the VBA Code that now stopped working:

Private Sub mySub()
    Dim dotnetRTFBox As System_Windows_Forms.RichTextBox
    Set dotnetRTFBox = New System_Windows_Forms.RichTextBox

Now, the line beginning with "Set dotnetRTFBox" gives:

Runtime error '429'
ActiveX component can't create object.

I have used this macro every 2-3 months for last 3 years and it worked. Last time I have used it was in 5/2019. But now it gives me the error.

I looked into help page ActiveX component can't create object or return reference to this object (Error 429). As one of possible reasons it says: The class isn't registered.

I have used ActiveXHelper and RegDllView from Nirsoft and none of the tools showed System.Windows.Forms.tlb or System.Windows.Forms.dll as being registered even thought that the files does exist in the specified location.

How could I repair it?

(I use 32-bit Office 365 Personal on 64-bit W10 1809, build 17763.864.)

Prorok Rak
  • 11
  • 2
  • No, that is not supposed to work. Never worked before either. The .tlb file is useful to, say, have a RichTextBox as a method parameter but the factories are not registered. Only BCL types are creatable. Write your own [ComVisible] class library to get ahead. – Hans Passant Dec 15 '19 at 11:09
  • @hans-pasant Method I used in my project was found on this thread: https://stackoverflow.com/questions/42576291/convert-rtf-rich-text-format-code-into-plain-text-in-excel And as I mentioned, it worked for quite some time without any problems. I didn't have to do anything special to make the RichTextBox control work in my VBA project. I just went into VBA Project Editor menu _Add-Ins > References_, checked "System_Windows_Forms" checkbox and that was it. I just wondered what I could do to make it work again. – Prorok Rak Dec 15 '19 at 16:59
  • @hans-pasant As for your suggestion `Write your own [ComVisible] class library` I don't know how to do that in my Excel VBA project. I would need more information about how to do that. – Prorok Rak Dec 15 '19 at 17:01

0 Answers0