Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error creating object in Class module - 429 ActiveX component can't create object

Status
Not open for further replies.

lameid

Programmer
Jan 31, 2001
4,207
0
0
US
This is weird. This code essentially works if I do not use a Class Module and works with either early or late binding.
In the Class module, I receive the error setting rfFaxServer. The code below is just an excerpt of the key elements. I have a working procedure that sets the fax server object exactly the same way but with all the variables declared within the procedure (scoped to the procedure). Aside from this little scope difference the only thing I see different is that this is a Class module and this is a constructor.

The idea is really simple. Make a class that opens the top level fax server and then iteratively call a sendfax method and possibly implement additional features like resending faxes that failed on the first attempt. This code uses the RightFax API.

Code:
Private rfFaxServer As Object 'New RFCOMAPILib.FaxServer
Private rfFax As Object 'RFCOMAPILib.Fax

Private Sub Class_Initialize()
  
  Set rfFaxServer = CreateObject("RFCOMAPILib.FaxServer") 'Run-time error '429'
                                                          'ActiveX component can't create object
  
      With rfFaxServer
        .ServerName = conFaxServer 'Defined and not included in the excerpt
        .Protocol = 6 'Right Fax constant value cpSecTCPIP
        ' Use for User NT Authentication...
        .AuthorizationUserID = Environ("UserName") 'Perhaps a bit lazy but should fail if environment variable hacked
        .UseNTAuthentication = True
    End With
End Sub

I don't get it... I have a PDF Class module that has a constructor that starts like the below and works. In fairness, it is a different project / file.

Code:
Private Sub Class_Initialize()

    'Initializations.
    
    Set fso = CreateObject("Scripting.FileSystemObject") 'New FileSystemObject 'Use late binding
    
    Set PDFApp = CreateObject("AcroExch.App")
    Set TargetDocument = CreateObject("AcroExch.PDDoc")
    Set Part2Document = CreateObject("AcroExch.PDDoc")

I forgot to kitchen sink compiled code issues, something for tomorrow but I sincerely doubt that it is the issue.

Any thoughts, wild guesses or condolences?

If I get desperate I guess I could declare the Fax server outside of a send fax function and pass it as a parameter, so much for my dream of a bigger class and cleanliness of simple object declaration without setup properties. Setup properties ... I could pass my server variable to a Pseudo-constructor procedure that has the properties.
 
I did some more digging and playing...

Paragraph corrected from original version to specify "Early" instead of "Late" binding:
Early binding simply does not work as the Fax Server has to be instantiated with the new keyword and apparently a regular module. I am guessing something can be done with permissions to prevent certain declarations... All grey area to me but the MS help topic mentioned not having permissions to the Type library as an issue in getting that error.

Code:
Public Function rfFaxServer(Optional SetNothing As Boolean = False) As Object
  Static rfFaxServerInternal As New RFCOMAPILib.FaxServer
  
  If SetNothing = True Then
    Set rfFaxServerInternal = Nothing
  Else
    If rfFaxServerInternal Is Nothing Then
      Set rfFaxServerInternal = CreateObject("RFCOMAPILib.FaxServer") 'Run-time error '429'
                                                              'ActiveX component can't create object
      
          With rfFaxServerInternal
            .ServerName = conFaxServer 'Constant set elsewhere
            .Protocol = 6 'Right Fax constrant value cpSecTCPIP
            ' Use for User NT Authentication...
            .AuthorizationUserID = Environ("UserName") 'Perhaps a bit lazy but should fail if a hack
            .UseNTAuthentication = True
        End With
    Else
      
    End If
  End If
  Set rfFaxServer = rfFaxServerInternal
End Function
 
Interesting, to preserve names, I renamed the function and used it to initialize and destroy the class object. One line of code each. And it can go in the class module... Just not a constructor directly. [ponder]

If someone could shed some light on permissions or what is going on, I would appreciate it.
 
Out of curiosity, try running your host application (Excel or Access or ...?) As Administrator.
 
Hmmm - I'm not following your last post. Could you post the code of the class module where (I think) you say it works?
 
>Late binding simply does not work
I don't think that is the issue, as Rightfax works in Vbscript, which can only use late binding ...
 
Strongm, I miswrote. EARLY binding simply does not work.

DjangMan, I don't have the ability to run as administrator in this environment and no right fax at home.

Mocking up a version excerpt of the class code below...

Code:
Private rfFaxServer As Object 'New RFCOMAPILib.FaxServer
Private rfFax As Object 'RFCOMAPILib.Fax

Private Sub Class_Initialize()
  
  Set rfFaxServer = rfFaxServerObject

End sub

Public Function rfFaxServerObject(Optional SetNothing As Boolean = False) As Object
  Static rfFaxServerInternal As New RFCOMAPILib.FaxServer
  
  If SetNothing = True Then
    Set rfFaxServerInternal = Nothing
  Else
    If rfFaxServerInternal Is Nothing Then
      Set rfFaxServerInternal = CreateObject("RFCOMAPILib.FaxServer") 'Run-time error '429'
                                                              'ActiveX component can't create object
      
          With rfFaxServerInternal
            .ServerName = conFaxServer 'Constant set elsewhere
            .Protocol = 6 'Right Fax constrant value cpSecTCPIP
            ' Use for User NT Authentication...
            .AuthorizationUserID = Environ("UserName") 'Perhaps a bit lazy but should fail if a hack
            .UseNTAuthentication = True
        End With
    Else
      
    End If
  End If
  Set rfFaxServerObject= rfFaxServerInternal
End Function
 
Er - this code example is early binding. Is it an example of what does not work, then?
 
I am all over the place with negatives and confusing myself. Late binding did not work. Early binding did. Even Early binding did not work in the class constructor (Class_Initialize) directly, I had to farm it out to a function.
 
>Late binding did not work

Ok - so … something else must be going on, since we know that in theory late binding works OK with RightFax (since it works with e.g. VBScript, which only does late binding). First off, might I suggest that use Dependency Walker to see if there are any dependency issues with RFCOMAPILib. If you don't have a copy, then you can find it here
 
Unfortunately, I am not going to be able to load outside software. It works this way and I suspect whatever goofy issue there is with the software, is likely replicated to multiple machines. So I think I will keep with my path of least resistance, it works this way.

It had not occurred to me to try it on another machine because of a potential install issue.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top