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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Faxserver Object

Status
Not open for further replies.

Error7

Programmer
Jul 5, 2002
656
GB
I found the following code on the internet and have managed to get it working ok (albeit a bit temperamental). My main problem is that the code sends the same fax several times, even though each transmission is successful.

Dim FaxServer As Object
Dim FaxDoc As Object

On Error GoTo ErrHandler

'Create FaxServer object...
Set FaxServer = CreateObject("FaxServer.FaxServer")

FaxServer.Connect ("\\" & Host Name of PC goes here)

'Create document
Set FaxDoc = FaxServer.CreateDocument("Test.txt")

FaxDoc.FaxNumber = "A valid fax number"

FaxDoc.Send

Set FaxDoc = Nothing

FaxServer.Disconnect

Set FaxServer = Nothing

Can anybody shed any light on this?

(Incidentally I believe it's W2k and NT only)

Alan

[gray]Experience is something you don't get until just after you need it.[/gray]
 
Installed SP4 and that seems to have cured the problem.

[gray]Experience is something you don't get until just after you need it.[/gray]
 
Hi,

What Fax Server are you using and can you fax any document (jpg, word doc, report)?

What I'm trying to accomplish is to allow a user to fax a document automatically to the company fax machine. Do I need to have a fax server for this to occur? I tried code similar to what you have above but get an error in the connection property stating that "Connection to fax server failed."

If you could shed some light to this, I'll appreciate it.

Thanks!
 
The Fax Server comes with W2k and XP. If you are using W2k then you will need SP4.

We run this several hours each weekday through a USB modem. It's very stable.

I'm pretty sure that this example code will get you started.

Dim FaxServer As Object
Dim FaxDoc As Object

'Create FaxServer object...
Set FaxServer = CreateObject("FaxServer.FaxServer")

FaxServer.Connect ("\\" & Host Name of PC goes here)
I use "FaxServer.Connect ("\\" & Winsock1.LocalHostName)" so that it's portable between machines.

'Create document
Set FaxDoc = FaxServer.CreateDocument("Test.txt")
This MUST be the full path and filename of the document to be faxed.

FaxDoc.FaxNumber = "A valid fax number"

FaxDoc.Send

Set FaxDoc = Nothing

FaxServer.Disconnect

Set FaxServer = Nothing

Alan

[gray]Experience is something you don't get until just after you need it.[/gray]
 
Sorry, I forgot to mention that we fax .doc, .txt, .rtf, .jpg.

The only problem I have experienced is with .bmp.

Alan

[gray]Experience is something you don't get until just after you need it.[/gray]
 
Hi Alan,

I have Win2000 w/ SP4 installed.

I tried working with the code you had written but the methods wouldn't show up for FaxServer or FaxDocument. So this is the code that I have so far:

Code:
Dim objFaxServer As FAXCOMEXLib.faxserver
Dim objFaxDocument As FAXCOMEXLib.FaxDocument
Dim objFaxDevice As FAXCOMEXLib.FaxDevice
dim iValue as integer

Set objFaxServer = New FAXCOMEXLib.faxserver
Set objFaxDocument = New FAXCOMEXLib.FaxDocument
objFaxServer.Connect ("\\srvrapps")
[\code]

A couple of questions:

1) Are there any special configurations that I need to make in order to have the fax server running?

2) I'm still having problem with the Connect property.  The outgoing faxes go thru the computer name \\svrapps, which is connected to the fax, so I tried the connect method above and got the "connection to server failed".  Then added a winsock control and tried 
[code]
iValue = Winsock1.Connect ("\\svrapps", "80")
objFaxServer.Connect ("\\srvrapps")
[\code]
but not having luck with that either.  Any suggestions?

Thanks.
 
According to " FAXCOMEXLib is XP. You should use "FaxServer" for 2000.

I don't know what your problem is unfortunately. Doing a Google search it seems that some people manage to get FaxServer to work and others don't!

This is example code from "
Public Function SendFax(FileName As Variant, FaxMachine As Variant, FaxNumber As Variant)

Set FaxServer = CreateObject("FaxServer.FaxServer")
FaxServer.Connect ("\\" & FaxMachine)
Set FaxDoc = FaxServer.CreateDocument(FileName)
With FaxDoc
.FaxNumber = FaxNumber
.Send
End With


Set FaxDoc = Nothing
Set FaxServer = Nothing

End Function

Check to make sure you have Faxcom.dll in your System32 folder.

Alan

[gray]Experience is something you don't get until just after you need it.[/gray]
 
Well, I just found out that I'm suppose to connect to a Win 2k3 Server and now the Connect property works fine, but now get an error when using the ConnectedSubmit property.

I get Run time error '-21470424894 (80070002)': Operation Failed. Not sure if you came across that error.

Here is the code

Dim objFaxServer As FAXCOMEXLib.faxserver
Dim objFaxDocument As FAXCOMEXLib.FaxDocument
Dim objFaxDevice As FAXCOMEXLib.FaxDevice
dim jobid as variant

Set objFaxServer = New FAXCOMEXLib.faxserver
Set objFaxDocument = New FAXCOMEXLib.FaxDocument
objFaxServer.Connect ("\\svrwindows")
Set objFaxDevice = objFaxDevice.GetDevices.Item(5)
objFaxDocument.Body = "C:\Test.txt"
objFaxDocument.Recepients.Add "fax #", "Test"
jobid = objFaxDocument.ConnectedSubmit(objFaxServer)

I tried following the code from the support.microsoft.com hyperlink you provided, but the intellisense didn't kick in so I'm thinking that the code with FaxComExLib should be followed for winxp, win2k3.

The sandler code is pretty good..Tried adding the error handler and received the error message that "Object is required", but I'm not sure what that message implies to the code I have.
 
I can't help you any further with this. It's not my specialist subject. I got it working on w2k more by luck than skill. There just isn't much help available on the web and what little there is can be confusing.

Alan

[gray]Experience is something you don't get until just after you need it.[/gray]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top