TommyF
Technical User
- Oct 28, 2001
- 104
I am having problems with the following, this was a sub that works in Microsoft Access and I am trying to get it to work inVB. I am trying to send a fax using Winfax 9 but am finding that ths sub does send the report but not the fax number and name etc. I downloaded this code from Symantec about a year or so ago and have downloaded some new code from there sight this week but am still finding that no information gets sent to winfax. I have Winfax Automation service selected in the references. Ihave also tried the sendobject method. Am I missing something?
Dim MSAccess As Access.Application
On Error GoTo HandleError
If Programming_Mode Then On Error GoTo 0
'----
Dim tempSendObj As Object
Dim tempRetVal As Integer
Dim strPhNmb As String
Dim strAreaCode As String
Dim Msg_str As String
Dim MBType As Long
Dim Title As String
Dim dr As ljg_Device_Nm
Dim org_dv As ljg_Org_Device_Nm
Dim int_Dflt As Boolean
Dim dr_Device As String
Dim dr_Driver As String
Dim dr_Port As String
Dim lngBillingcode As Long
'DoCmd.Requery
'-------- figure out Phone Number
Select Case Len(Trim(Me.faxno))
Case 12 ' has Area Code
strAreaCode = Left(Me.faxno, 5)
strPhNmb = Mid(Me.faxno, 7)
Case 6 ' no area code
strAreaCode = ""
strPhNmb = Trim(Me.faxno)
Case Else
MsgBox "Bad Phone Number - we are looking area code and number or number only."
Me.faxno.SetFocus
GoTo ProcedureDone
End Select
'--- Check for Name & Company
If Len(Trim(Me.comp & Me.to & ""
) < 5 Then
MsgBox "You must have a Person or a Company to send to."
Me.to.SetFocus
GoTo ProcedureDone
End If
If Me.GrpRpts = 1 Then 'Access Report
'Change the defalt printer to WinFax 8.0 / 9 ----------------------------
dr_Device = "WinFax"
dr_Driver = "WinFax"
dr_Port = "FaxModem" 'PUB:
'--------------- Get Defalt Printer info & save it for later
'returns false if no defalt printer
int_Dflt = ljg_GetDefaultPrinter(org_dv)
'--------------- Set new printer as default
With dr
.drDeviceName = dr_Device
.drDriverName = dr_Driver
.drPort = dr_Port
End With
If Not ljg_SetDefaultPrinter(dr) Then
Msg_str = "Unable to reset Fax as the default printer." & vbCrLf
MBType = 0 ' OK
Title = "Fax Printer Not Installed"
MsgBox Msg_str, MBType, Title
GoTo ProcedureDone
End If
End If
'------------- Start Conversations with WinFax
Dim objWFXSend As New wfxctl32.CSDKSend '<--- By using this line you get the pull down list of methods (Called Early Binding)
' To use this line you need to have 'WinFax Automation Server' Checked in your references
' To Check 'WinFax Automation Server' open a module then from the menu
' Tools | References | and find 'WinFax Automation Server' - If you can't find it
' Try browsing for C:\Program Files\Symantec\WinFax\wfxctl32.tlb
' This will also Open the 'WinFax Controller' in your task Bar Tray
'Dim objWFXSend As Object '<--- If the above line give you problems use these two lines (Late Binding)
'Set objWFXSend = CreateObject("WinFax.SDKSend"
With objWFXSend
'.SetHold (Me.grphold) '<---- Sometime is this is at the bottom of the code things hang up???
'Note if you set the below date - time WinFax Ignores the "SetHold" and sends the fax on the
' Appropriate Date and Time - Note it cannot be past date or time
.SetDate ("10/08/98"
.SetTime ("8:30:00"
'--- To:
.SetCountryCode (""
.SetAreaCode (strAreaCode)
.SetNumber (strPhNmb)
.SetTo (Me.to)
.SetCompany (Me.comp & ""
'--- Billing code - KeyWords
'.EnableBillingCodeKeyWords (1) '<-- You need to enable key codes first
' lngBillingcode = lngBillingcode + 22 ' Note you can lookup faxes on BillingCode and/or KeyWords
' You might want a number on the Access Record that is the same as Billing Code
'.SetBillingCode (lngBillingcode) '<-- You will need to show Billing code in WinFax folders to see the billing code
'.SetKeywords ("Larry's the Key"
'<-- You will need to show KeyWords in WinFax folders to see the KeyWords
'--- Add Recipient - You can loop through and add multiple recipiants
.AddRecipient
'----- Cover Page Info
.SetSubject (Me.subject & ""
If Me.grpcoverpage < 3 Then
.SetCoverText ("Test Cover Text"
' If the next 3 lines are not sent to win fax there will be no cover page
If Me.grpcoverpage = 2 Then
.SetCoverFile (Me) ' Note if file is not specified the quick cover will print
End If
End If
'------ Attachment or report
'If Me.GrpRpts = 2 Then
' .AddAttachmentFile (Me.TxtRptAttachmentsFile)
'Else
' .SetPrintFromApp (1)
'End If
'.ShowSendScreen (1) '<------ I'don't understand what this does
'.SetResolution (intResolution)
'The below causes a creptic question to be asked at times - How do we stop that?
'.SetDeleteAfterSend (Me.grpDelete) '1= Delete fax after sending successfully 0=keep (0 default)
'1= shows progress screen 0= does not Show screen (1 default)
'.ShowCallProgess (Me.grpProgressScreen) '<---- Notice the 'r' missing this works in WinFax 8 & 9
'.ShowCallProgress (me.grpProgressScreen)'<---- Works only in WinFax9
' Start Faxing
.Send (0)
Do While .IsReadyToPrint = 0
DoEvents
Loop
'Access97 command ********************
If Me.GrpRpts = 1 Then 'Access Report
Set MSAccess = CreateObject("Access.Application"
MSAccess.OpenCurrentDatabase "c:\documents and Settings\thomas\desktop\saturn\saturn97.mdb"
MSAccess.DoCmd.OpenReport "faxemailcust", acViewNormal, , "ID = " & Me.faxid
'DoCmd.OpenReport "faxemailcust", acViewNormal, , "ID = " & Me.ID
End If
'Excel97 Command ********************
'ActiveSheet.PrintOut
'Word97 command ********************
'ActiveDocument.PrintOut
SleepAPI 200 ' Don't remove - tried 50, Send Dialog!
.Done
SleepAPI 200 ' Don't remove - tried 50, Send Dialog!
End With
objWFXSend.LeaveRunning ' If we started WinFax with 'Dim objWFXSend As New wfxctl32.CSDKSend' this will leave it running.
'--------------- Set back to old default printer
If Me.GrpRpts = 1 Then 'Access Report
With dr
.drDeviceName = org_dv.drDeviceName
.drDriverName = org_dv.drDriverName
.drPort = org_dv.drPort
End With
If Not ljg_SetDefaultPrinter(dr) Then
MsgBox "Unable to >>reset<< the default printer."
End If
End If
ProcedureDone:
Exit Sub
HandleError:
MsgBox Err.Description, vbCritical, "Error " & Err & " in ButtonFax1_Click"
Resume ProcedureDone
Dim MSAccess As Access.Application
On Error GoTo HandleError
If Programming_Mode Then On Error GoTo 0
'----
Dim tempSendObj As Object
Dim tempRetVal As Integer
Dim strPhNmb As String
Dim strAreaCode As String
Dim Msg_str As String
Dim MBType As Long
Dim Title As String
Dim dr As ljg_Device_Nm
Dim org_dv As ljg_Org_Device_Nm
Dim int_Dflt As Boolean
Dim dr_Device As String
Dim dr_Driver As String
Dim dr_Port As String
Dim lngBillingcode As Long
'DoCmd.Requery
'-------- figure out Phone Number
Select Case Len(Trim(Me.faxno))
Case 12 ' has Area Code
strAreaCode = Left(Me.faxno, 5)
strPhNmb = Mid(Me.faxno, 7)
Case 6 ' no area code
strAreaCode = ""
strPhNmb = Trim(Me.faxno)
Case Else
MsgBox "Bad Phone Number - we are looking area code and number or number only."
Me.faxno.SetFocus
GoTo ProcedureDone
End Select
'--- Check for Name & Company
If Len(Trim(Me.comp & Me.to & ""
MsgBox "You must have a Person or a Company to send to."
Me.to.SetFocus
GoTo ProcedureDone
End If
If Me.GrpRpts = 1 Then 'Access Report
'Change the defalt printer to WinFax 8.0 / 9 ----------------------------
dr_Device = "WinFax"
dr_Driver = "WinFax"
dr_Port = "FaxModem" 'PUB:
'--------------- Get Defalt Printer info & save it for later
'returns false if no defalt printer
int_Dflt = ljg_GetDefaultPrinter(org_dv)
'--------------- Set new printer as default
With dr
.drDeviceName = dr_Device
.drDriverName = dr_Driver
.drPort = dr_Port
End With
If Not ljg_SetDefaultPrinter(dr) Then
Msg_str = "Unable to reset Fax as the default printer." & vbCrLf
MBType = 0 ' OK
Title = "Fax Printer Not Installed"
MsgBox Msg_str, MBType, Title
GoTo ProcedureDone
End If
End If
'------------- Start Conversations with WinFax
Dim objWFXSend As New wfxctl32.CSDKSend '<--- By using this line you get the pull down list of methods (Called Early Binding)
' To use this line you need to have 'WinFax Automation Server' Checked in your references
' To Check 'WinFax Automation Server' open a module then from the menu
' Tools | References | and find 'WinFax Automation Server' - If you can't find it
' Try browsing for C:\Program Files\Symantec\WinFax\wfxctl32.tlb
' This will also Open the 'WinFax Controller' in your task Bar Tray
'Dim objWFXSend As Object '<--- If the above line give you problems use these two lines (Late Binding)
'Set objWFXSend = CreateObject("WinFax.SDKSend"
With objWFXSend
'.SetHold (Me.grphold) '<---- Sometime is this is at the bottom of the code things hang up???
'Note if you set the below date - time WinFax Ignores the "SetHold" and sends the fax on the
' Appropriate Date and Time - Note it cannot be past date or time
.SetDate ("10/08/98"
.SetTime ("8:30:00"
'--- To:
.SetCountryCode (""
.SetAreaCode (strAreaCode)
.SetNumber (strPhNmb)
.SetTo (Me.to)
.SetCompany (Me.comp & ""
'--- Billing code - KeyWords
'.EnableBillingCodeKeyWords (1) '<-- You need to enable key codes first
' lngBillingcode = lngBillingcode + 22 ' Note you can lookup faxes on BillingCode and/or KeyWords
' You might want a number on the Access Record that is the same as Billing Code
'.SetBillingCode (lngBillingcode) '<-- You will need to show Billing code in WinFax folders to see the billing code
'.SetKeywords ("Larry's the Key"
'--- Add Recipient - You can loop through and add multiple recipiants
.AddRecipient
'----- Cover Page Info
.SetSubject (Me.subject & ""
If Me.grpcoverpage < 3 Then
.SetCoverText ("Test Cover Text"
If Me.grpcoverpage = 2 Then
.SetCoverFile (Me) ' Note if file is not specified the quick cover will print
End If
End If
'------ Attachment or report
'If Me.GrpRpts = 2 Then
' .AddAttachmentFile (Me.TxtRptAttachmentsFile)
'Else
' .SetPrintFromApp (1)
'End If
'.ShowSendScreen (1) '<------ I'don't understand what this does
'.SetResolution (intResolution)
'The below causes a creptic question to be asked at times - How do we stop that?
'.SetDeleteAfterSend (Me.grpDelete) '1= Delete fax after sending successfully 0=keep (0 default)
'1= shows progress screen 0= does not Show screen (1 default)
'.ShowCallProgess (Me.grpProgressScreen) '<---- Notice the 'r' missing this works in WinFax 8 & 9
'.ShowCallProgress (me.grpProgressScreen)'<---- Works only in WinFax9
' Start Faxing
.Send (0)
Do While .IsReadyToPrint = 0
DoEvents
Loop
'Access97 command ********************
If Me.GrpRpts = 1 Then 'Access Report
Set MSAccess = CreateObject("Access.Application"
MSAccess.OpenCurrentDatabase "c:\documents and Settings\thomas\desktop\saturn\saturn97.mdb"
MSAccess.DoCmd.OpenReport "faxemailcust", acViewNormal, , "ID = " & Me.faxid
'DoCmd.OpenReport "faxemailcust", acViewNormal, , "ID = " & Me.ID
End If
'Excel97 Command ********************
'ActiveSheet.PrintOut
'Word97 command ********************
'ActiveDocument.PrintOut
SleepAPI 200 ' Don't remove - tried 50, Send Dialog!
.Done
SleepAPI 200 ' Don't remove - tried 50, Send Dialog!
End With
objWFXSend.LeaveRunning ' If we started WinFax with 'Dim objWFXSend As New wfxctl32.CSDKSend' this will leave it running.
'--------------- Set back to old default printer
If Me.GrpRpts = 1 Then 'Access Report
With dr
.drDeviceName = org_dv.drDeviceName
.drDriverName = org_dv.drDriverName
.drPort = org_dv.drPort
End With
If Not ljg_SetDefaultPrinter(dr) Then
MsgBox "Unable to >>reset<< the default printer."
End If
End If
ProcedureDone:
Exit Sub
HandleError:
MsgBox Err.Description, vbCritical, "Error " & Err & " in ButtonFax1_Click"
Resume ProcedureDone