Search code examples
excelvbarightfaxdocx-mailmerge

VBA excel rightfax


Currently I have a process in Excel that a user clicks a specific command and then takes the data from Excel and creates a mailmerge in Word. I then want it to the file(s) via RightFax, but I am having trouble at the Set oNewFax, when stepping through I get a run-time error '-2147023174 (800706ba)':. Any help is greatly appreciated!

    Sub RightFax()

Dim oFaxServer As RFCOMAPILib.faxserver
Dim oNewFax As RFCOMAPILib.fax
Set oFaxServer = New RFCOMAPILib.faxserver
oFaxServer.ServerName = "RightFax Fax Printer"
oFaxServer.UseNTAuthentication = True
Set oNewFax = oFaxServer.User.Faxes.Create

oNewFax.ToFaxNumber = "##########"
oNewFax.ToName = "Testing"
oNewFax.EmailSubject = ""
oNewFax.Attachments.Add ("######")
oNewFax.HasCoversheet = False 'Change to true if you want a coversheet 
generated
oNewFax.Send
Set oFaxServer = Nothing
Set oNewFax = Nothing

End Sub

Solution

  • My working code creates the fax object like below...

    Set oNewFax = oFaxServer.CreateObject(coFax)