owinterton
08-08-2003, 04:48 PM
I finally got this blasted thing to work.... Here is some code that I tried. I got it to automate on a timer event so just set the timer event (or put in any event) and it should work. I put in some queries in there to determine which files had already been faxed. I'm using VBA code in Access 2000, on a Windows 98 Computer with WinFax 10.
My next obstacle is to get the EventNotification Object to detect when the fax has actually sent the item through the Fax machine instead of getting it to the inbox. Does Anyone have any ideas on that matter, I'm new to programming that object. I know you must use the "status" function but no idea on syntax or coding of it.
<Code>
Option Compare Database
Private Sub Form_Load()
Me.TimerInterval = 10000
End Sub
Private Sub Form_Timer()
Dim vARst As ADODB.Recordset
Set vARst = New ADODB.Recordset
Dim vCounter As Integer
Dim vSQL As String
vSQL = "SELECT tblSignin.SigninStatus FROM tblSignin " & _
"WHERE (((tblSignin.SigninStatus)='Fax'))"
vARst.CursorType = adOpenKeyset
vARst.CursorLocation = adUseClient
vARst.LockType = adLockBatchOptimistic
vARst.Open vSQL, CurrentProject.Connection
vCounter = vARst.RecordCount
If vCounter > 0 Then
Dim ret As Integer
Dim strRecipient As String
Dim strFaxNumber As String
Dim RetCode
'Convert the Access Report to an RTF file
Dim strFileName1 As String
strFileName1 = "C:\FaxReport.rtf"
If Dir(strFileName1) <> vbNullString Then
Kill strFileName1
End If
DoCmd.OutputTo acOutputReport, "rpt_SigninFax", acFormatRTF, strFileName1, False
'String of Numbers and Recipients to fax Reports to
Dim vAreaCode(1) As String
Dim vRecipient(1) As String
Dim vPhoneNumber(1) As String
'-----------------------------------
vAreaCode(1) = "1209"
'-----------------------------------
vPhoneNumber(1) = "555-5555"
'-----------------------------------
vRecipient(1) = "Olaf Winterton"
'-----------------------------------
Dim I As Integer
I = 0
For I = 1 To 2
Dim sendObj As Object
Set sendObj = CreateObject("WinFax.SDKSend8.0")
RetCode = sendObj.SetClientID("Client Name")
'BEGIN RECIPIENT SETTINGS
RetCode = sendObj.SetTo(vRecipient(I))
RetCode = sendObj.SetAreaCode(vAreaCode(I))
RetCode = sendObj.SetNumber(vPhoneNumber(I))
RetCode = sendObj.SetTypeByName("Fax")
RetCode = sendObj.SetCompany("Herzog Transit Services")
'Begin Job Settings
RetCode = sendObj.SetResolution(1)
RetCode = sendObj.SetDeleteAfterSend(1)
'RetCode = sendObj.SetQuickCover(1)
RetCode = sendObj.SetSubject("ACE Trip Report")
RetCode = sendObj.SetCoverFile("C:\Program Files\WinFax\Cover\ACEReportCover.CVP")
RetCode = sendObj.SetCoverText(" " & "ACE Trip Reports")
RetCode = sendObj.ShowCallProgess(1)
RetCode = sendObj.AddRecipient()
Dim strFileName As String
strFileName = "c:\FaxReport.rtf"
sendObj.MakeAttachment "FaxReport", "C:\", 0
If sendObj.AddAttachmentFile(strFileName) = 1 Then
MsgBox ("Failed when adding attachment!")
End If
RetCode = sendObj.RecievedEvent(1)
ret = sendObj.Send(0)
RetCode = sendObj.ShowSendScreen(1)
SleepAPI (200)
sendObj.Done
SleepAPI (200)
Next
Set sendObj = Nothing
Dim vAppend As ADODB.Recordset
Set vAppend = New ADODB.Recordset
Dim vAppCounter As Integer
Dim vSQL2 As String
vSQL2 = "UPDATE tblSignin SET tblSignin.SigninStatus = 'APPEND'" & _
"WHERE (((tblSignin.SigninStatus)='FAX'))"
vAppend.CursorType = adOpenKeyset
vAppend.CursorLocation = adUseClient
vAppend.LockType = adLockBatchOptimistic
vAppend.Open vSQL2, CurrentProject.Connection
Else
Exit Sub
End If
End Sub
</Code>
My next obstacle is to get the EventNotification Object to detect when the fax has actually sent the item through the Fax machine instead of getting it to the inbox. Does Anyone have any ideas on that matter, I'm new to programming that object. I know you must use the "status" function but no idea on syntax or coding of it.
<Code>
Option Compare Database
Private Sub Form_Load()
Me.TimerInterval = 10000
End Sub
Private Sub Form_Timer()
Dim vARst As ADODB.Recordset
Set vARst = New ADODB.Recordset
Dim vCounter As Integer
Dim vSQL As String
vSQL = "SELECT tblSignin.SigninStatus FROM tblSignin " & _
"WHERE (((tblSignin.SigninStatus)='Fax'))"
vARst.CursorType = adOpenKeyset
vARst.CursorLocation = adUseClient
vARst.LockType = adLockBatchOptimistic
vARst.Open vSQL, CurrentProject.Connection
vCounter = vARst.RecordCount
If vCounter > 0 Then
Dim ret As Integer
Dim strRecipient As String
Dim strFaxNumber As String
Dim RetCode
'Convert the Access Report to an RTF file
Dim strFileName1 As String
strFileName1 = "C:\FaxReport.rtf"
If Dir(strFileName1) <> vbNullString Then
Kill strFileName1
End If
DoCmd.OutputTo acOutputReport, "rpt_SigninFax", acFormatRTF, strFileName1, False
'String of Numbers and Recipients to fax Reports to
Dim vAreaCode(1) As String
Dim vRecipient(1) As String
Dim vPhoneNumber(1) As String
'-----------------------------------
vAreaCode(1) = "1209"
'-----------------------------------
vPhoneNumber(1) = "555-5555"
'-----------------------------------
vRecipient(1) = "Olaf Winterton"
'-----------------------------------
Dim I As Integer
I = 0
For I = 1 To 2
Dim sendObj As Object
Set sendObj = CreateObject("WinFax.SDKSend8.0")
RetCode = sendObj.SetClientID("Client Name")
'BEGIN RECIPIENT SETTINGS
RetCode = sendObj.SetTo(vRecipient(I))
RetCode = sendObj.SetAreaCode(vAreaCode(I))
RetCode = sendObj.SetNumber(vPhoneNumber(I))
RetCode = sendObj.SetTypeByName("Fax")
RetCode = sendObj.SetCompany("Herzog Transit Services")
'Begin Job Settings
RetCode = sendObj.SetResolution(1)
RetCode = sendObj.SetDeleteAfterSend(1)
'RetCode = sendObj.SetQuickCover(1)
RetCode = sendObj.SetSubject("ACE Trip Report")
RetCode = sendObj.SetCoverFile("C:\Program Files\WinFax\Cover\ACEReportCover.CVP")
RetCode = sendObj.SetCoverText(" " & "ACE Trip Reports")
RetCode = sendObj.ShowCallProgess(1)
RetCode = sendObj.AddRecipient()
Dim strFileName As String
strFileName = "c:\FaxReport.rtf"
sendObj.MakeAttachment "FaxReport", "C:\", 0
If sendObj.AddAttachmentFile(strFileName) = 1 Then
MsgBox ("Failed when adding attachment!")
End If
RetCode = sendObj.RecievedEvent(1)
ret = sendObj.Send(0)
RetCode = sendObj.ShowSendScreen(1)
SleepAPI (200)
sendObj.Done
SleepAPI (200)
Next
Set sendObj = Nothing
Dim vAppend As ADODB.Recordset
Set vAppend = New ADODB.Recordset
Dim vAppCounter As Integer
Dim vSQL2 As String
vSQL2 = "UPDATE tblSignin SET tblSignin.SigninStatus = 'APPEND'" & _
"WHERE (((tblSignin.SigninStatus)='FAX'))"
vAppend.CursorType = adOpenKeyset
vAppend.CursorLocation = adUseClient
vAppend.LockType = adLockBatchOptimistic
vAppend.Open vSQL2, CurrentProject.Connection
Else
Exit Sub
End If
End Sub
</Code>