HELP ME PLEASE ! I'm going crazy : Using VBA to send faxes under Windows XP Pro

P

Patrick Toledano

Hi,



I've some problems too with fax system under XP Pro.



So, I can send fax with symbolic printer driver with automatic installation
of XP. With that I can send manually a fax (I understand by manually without
any VB or VBA).



But I would like to run a proccess to mailmerge an excel datafile (record by
record because sometimes I send by fax, email or letter/printer) with a
personal word template. This does not run under XP (running correctly under
Windows Me) with the standard "ActiveDocument.MailMerge.Destination =
wdSendToFax". But this method doesnt run under Windows XP (dixit Microsoft).



After reading Microsoft support about faxing I've found different codes upon
"faxserver". I try this code .... And return code designate an error such as
"fax machine or modem doesnt exist". Thus, I verify my fax config... The
printer/fax exist but no fax/modem exists... SO create it with actual modem
(OLITEC Self memory V92). I test it my new config and work correctly.



All works correctly with 1 fax device found with

ID = 65541

Folders archives are correctly initiated and all other parameters of fax
server

FaxDocument is correctly initiated with all parameters (may be suspect Tapi
connection initiated to "nothing")

FaxDevices(1) is known by my module as "Olitec Self Memory V92 Ready"

collfaxdevices(1).UsedRoutingMethods(0)={92041A90-9AF2-11D0-ABF7-00C04FD91A4
E}

collfaxdevices(1).UsedRoutingMethods(1)={AEC1B37C-9AF2-11D0-ABF7-00C04FD91A4
E}

I dont know if these routing methods are important and corectly initiated





BUT...





I try a new time the following code without success (error code not existing
in MS knowledge base) !

Error number : 80070002, Operation failed

So the word application is blocked (I must do kill all word instances
Outlook included (word is my Outlook editor), I must kill Word programms and
Word process).



When I call back my word document after to delete word backup files to test
it a new time all macros are not running ... I must copy code to a new
document !!!!!





I'M GOING CRAZY!!!!!!!







++++++++++++++++++++++++++++++++++++++++++++++++++++

Patrick Toledano ([email protected] or +33 612 296 945)

++++++++++++++++++++++++++++++++++++++++++++++++++++



see code after

!

!

!

!





============================ SENDING FAX CODE TO TEST FAX FUNCTIONALITY
UNDER XP =====================================

Sub SendingFax()

Dim objFaxServer As FAXCOMEXLib.FaxServer

Dim objFaxDocument As New FAXCOMEXLib.FaxDocument

Dim objFaxJobs As FaxJobs

Dim objFaxJob As FaxJob

Dim JobID As Variant

Dim objFaxPorts As FaxPorts

Dim objFaxPort As FaxPort

Dim objFaxStatus As FaxStatus

Dim objFaxRoutingMethods As FaxRoutingMethods

Dim objFaxRoutingMethod As FaxRoutingMethod

Dim objSender As FaxSender



Dim collFaxDevices As FaxDevices

Dim objFaxDevice As FaxDevice

Dim collFaxDeviceProviders As FaxDeviceProviders

Dim objFaxDeviceProvider As FaxDeviceProvider

Dim i As Variant

Dim j, k, n As Long





'Error handling

On Error GoTo Error_Handler



'Connect to the fax server

Set objFaxServer = New FAXCOMEXLib.FaxServer

'objFaxServer.Connect System.PrivateProfileString("",
"HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\ComputerName\",
"ActiveComputerName")

objFaxServer.Connect ""



Set collFaxDeviceProviders = objFaxServer.GetDeviceProviders

n = collFaxDeviceProviders.Count



'Display the properties for each fax device provider

For j = 1 To n

Set objFaxDeviceProvider = collFaxDeviceProviders.Item(j)

MsgBox "Debug = " & objFaxDeviceProvider.Debug & _

vbCrLf & "Name = " & objFaxDeviceProvider.FriendlyName & _

vbCrLf & "Image name = " & objFaxDeviceProvider.ImageName & _

vbCrLf & "Init error code = " & objFaxDeviceProvider.InitErrorCode & _

vbCrLf & "Build and version = " & objFaxDeviceProvider.MajorBuild & "."
& _

objFaxDeviceProvider.MinorBuild & "." & _

objFaxDeviceProvider.MajorVersion & "." & _

objFaxDeviceProvider.MinorVersion & _

vbCrLf & "Status = " & objFaxDeviceProvider.Status & _

vbCrLf & "Tapi provider = " & objFaxDeviceProvider.TapiProviderName & _

vbCrLf & "Unique name = " & objFaxDeviceProvider.UniqueName



'Display the device ids for that provider

Dim DeviceArray() As Long

DeviceArray = objFaxDeviceProvider.DeviceIds

'UBound finds the size of the array

For k = 0 To UBound(DeviceArray)

MsgBox "Device ID: " & DeviceArray(k)

Next

Next



Set collFaxDevices = objFaxServer.GetDevices

MsgBox "This server has " & collFaxDevices.Count & " fax devices."



For i = 1 To collFaxDevices.Count

Set objFaxDevice = collFaxDevices.Item(i)

objFaxDevice.SendEnabled = True

MsgBox "Device ID for device number " & i & " is: " & objFaxDevice.ID

Next



'Set the fax body

objFaxDocument.Body = "Z:\Triangle\Modèles Triangles\DITO-Convocation du
mardi 08 octobre 2002.doc"



'Name the document

objFaxDocument.DocumentName = "My First Fax"



'Set the fax priority

'objFaxDocument.Priority = fptHIGH



'Add the recipient with the fax number 12225550100

objFaxDocument.Recipients.Add "0149000126", "Bud"



'Choose to attach the fax to the fax receipt

objFaxDocument.AttachFaxToReceipt = True



'Set the cover page type and the path to the cover page

'objFaxDocument.CoverPageType = fcptSERVER

'objFaxDocument.CoverPage = "Generic"



'Provide the cover page note

objFaxDocument.Note = "Here is the info you requested"



'Provide the address for the fax receipt

'objFaxDocument.ReceiptAddress = "(e-mail address removed)"



'Set the receipt type to email

'objFaxDocument.ReceiptType = frtMAIL



'Specify that the fax is to be sent at a particular time

'objFaxDocument.ScheduleType = fstSPECIFIC_TIME

'CDate converts the time to the Date data type

'objFaxDocument.ScheduleTime = CDate("4:35:47 PM")



objFaxDocument.Subject = "Today's fax"



'Set the sender properties.

objFaxDocument.Sender.Title = "Mr."

objFaxDocument.Sender.Name = "Bob"

objFaxDocument.Sender.City = "Cleveland Heights"

objFaxDocument.Sender.State = "Ohio"

objFaxDocument.Sender.Company = "Microsoft"

objFaxDocument.Sender.Country = "USA"

objFaxDocument.Sender.Email = "(e-mail address removed)"

objFaxDocument.Sender.FaxNumber = "12165555554"

objFaxDocument.Sender.HomePhone = "12165555555"

objFaxDocument.Sender.OfficeLocation = "Downtown"

objFaxDocument.Sender.OfficePhone = "12165555553"

objFaxDocument.Sender.StreetAddress = "123 Main Street"

objFaxDocument.Sender.Tsid = "Office fax machine"

objFaxDocument.Sender.ZipCode = "44118"

objFaxDocument.Sender.BillingCode = "23A54"

objFaxDocument.Sender.Department = "Accts Payable"



'Save sender information as default

'objFaxDocument.Sender.SaveDefaultSender



'Submit the document to the connected fax server

'and get back the job ID.



JobID = objFaxDocument.ConnectedSubmit(objFaxServer)



MsgBox "The Job ID is :" & JobID(0)

Exit Sub



Error_Handler:

'Implement error handling at the end of your subroutine. This
implementation is for demonstration purposes

MsgBox "Error number: " & Hex(Err.Number) & ", " & Err.Description



End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top