Ok here is something i got From the rptsmp00 (from Microsoft, tested and run on windows 95 and Winfax 7)and i am running windows XP Pro and Winfax 10.02. After modifying a couple things, for 1 it would not recognize that winfax was actually open, so i have some code to open winfax, and then DDE would need a specific date format which i changed. Now i am getting anoother error which im not sure what to do. Here is the complete Code:
Option Compare Database
Option Explicit
Global strInvoiceWhere
Declare Function FindWindow& Lib "user32" Alias "FindWindowA" (ByVal IpClassName As String, ByVal IpWindowName As String) ' WinFax only
Function WinFaxInvoices()
Dim dbsNorthwind As Database
Dim rstCustomers As Recordset
Dim intSendFaxReturnVal As Integer
Set dbsNorthwind = CurrentDb()
Set rstCustomers = dbsNorthwind.OpenRecordset("Customers", dbOpenDynaset)
intSendFaxReturnVal = -1
If MsgBox("Do you want to fax invoices" & Chr(13) & "to all customers using WinFax?", 4) = 6 Then
intSendFaxReturnVal = -1
With rstCustomers
Do Until .EOF Or intSendFaxReturnVal = 0
strInvoiceWhere = "[customerid] = '" & ![CustomerID] & "'"
intSendFaxReturnVal = SendWinFax(![ContactName], ![Fax], "rptWinFaxInvoice"
.MoveNext
Loop
End With
End If
End Function
Function SendWinFax(strFaxName As String, strFaxNumber As String, strReportName As String) As Integer
Dim lngChannelNumber As Long
Dim strFaxStatus As String
Dim FaxTime As String
Dim strRecipFaxNum As String
Dim strRecipTime As String
Dim strRecipDate As String
Dim strRecipName As String
Dim strRecipient As String
On Error GoTo SendWinFax_Error
Dim objWFXSend As New wfxctl32.CSDKSend
strRecipFaxNum = Chr$(34) & strFaxNumber & Chr$(34)
strRecipTime = Chr$(34) & Format$(Now, "h:nn:ss"
& Chr$(34)
strRecipDate = Chr$(34) & Format$(Date, "mm/dd/yy"
& Chr$(34)
strRecipName = Chr$(34) & left$(strFaxName, 24) & Chr$(34)
strRecipient = strRecipFaxNum & "," & strRecipTime & "," & strRecipDate & "," & strRecipName
lngChannelNumber = DDEInitiate("faxmng32", "CONTROL"
strFaxStatus = DDERequest(lngChannelNumber, "STATUS"
While strFaxStatus Like "Busy*"
strFaxStatus = DDERequest(lngChannelNumber, "STATUS"
Wend
lngChannelNumber = DDEInitiate("FAXMNG", "TRANSMIT"
DDEPoke lngChannelNumber, "Sendfax", "recipient(" & strRecipient & "
"
DDEPoke lngChannelNumber, "Sendfax", "showsendscreen(""0""
"
DoCmd.OpenReport strReportName, A_NORMAL
SendWinFax = -1
SendFax_Exit:
DDETerminateAll
lngChannelNumber = False
Exit Function
SendWinFax_Error:
MsgBox "Error:" + Error$, 0, "SendFaxl"
Resume SendFax_Exit
End Function
The error i get is Invalid Use of Null located in this line:
intSendFaxReturnVal = SendWinFax(![ContactName], ![Fax], "rptWinFaxInvoice"
Any Ideas?
Thanx Bill
Option Compare Database
Option Explicit
Global strInvoiceWhere
Declare Function FindWindow& Lib "user32" Alias "FindWindowA" (ByVal IpClassName As String, ByVal IpWindowName As String) ' WinFax only
Function WinFaxInvoices()
Dim dbsNorthwind As Database
Dim rstCustomers As Recordset
Dim intSendFaxReturnVal As Integer
Set dbsNorthwind = CurrentDb()
Set rstCustomers = dbsNorthwind.OpenRecordset("Customers", dbOpenDynaset)
intSendFaxReturnVal = -1
If MsgBox("Do you want to fax invoices" & Chr(13) & "to all customers using WinFax?", 4) = 6 Then
intSendFaxReturnVal = -1
With rstCustomers
Do Until .EOF Or intSendFaxReturnVal = 0
strInvoiceWhere = "[customerid] = '" & ![CustomerID] & "'"
intSendFaxReturnVal = SendWinFax(![ContactName], ![Fax], "rptWinFaxInvoice"
.MoveNext
Loop
End With
End If
End Function
Function SendWinFax(strFaxName As String, strFaxNumber As String, strReportName As String) As Integer
Dim lngChannelNumber As Long
Dim strFaxStatus As String
Dim FaxTime As String
Dim strRecipFaxNum As String
Dim strRecipTime As String
Dim strRecipDate As String
Dim strRecipName As String
Dim strRecipient As String
On Error GoTo SendWinFax_Error
Dim objWFXSend As New wfxctl32.CSDKSend
strRecipFaxNum = Chr$(34) & strFaxNumber & Chr$(34)
strRecipTime = Chr$(34) & Format$(Now, "h:nn:ss"
strRecipDate = Chr$(34) & Format$(Date, "mm/dd/yy"
strRecipName = Chr$(34) & left$(strFaxName, 24) & Chr$(34)
strRecipient = strRecipFaxNum & "," & strRecipTime & "," & strRecipDate & "," & strRecipName
lngChannelNumber = DDEInitiate("faxmng32", "CONTROL"
strFaxStatus = DDERequest(lngChannelNumber, "STATUS"
While strFaxStatus Like "Busy*"
strFaxStatus = DDERequest(lngChannelNumber, "STATUS"
Wend
lngChannelNumber = DDEInitiate("FAXMNG", "TRANSMIT"
DDEPoke lngChannelNumber, "Sendfax", "recipient(" & strRecipient & "
DDEPoke lngChannelNumber, "Sendfax", "showsendscreen(""0""
DoCmd.OpenReport strReportName, A_NORMAL
SendWinFax = -1
SendFax_Exit:
DDETerminateAll
lngChannelNumber = False
Exit Function
SendWinFax_Error:
MsgBox "Error:" + Error$, 0, "SendFaxl"
Resume SendFax_Exit
End Function
The error i get is Invalid Use of Null located in this line:
intSendFaxReturnVal = SendWinFax(![ContactName], ![Fax], "rptWinFaxInvoice"
Any Ideas?
Thanx Bill