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

Problems Sending to Winfax

Status
Not open for further replies.

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 & &quot;&quot;)) < 5 Then
MsgBox &quot;You must have a Person or a Company to send to.&quot;
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 = &quot;WinFax&quot;
dr_Driver = &quot;WinFax&quot;
dr_Port = &quot;FaxModem&quot; '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 = &quot;Unable to reset Fax as the default printer.&quot; & vbCrLf
MBType = 0 ' OK
Title = &quot;Fax Printer Not Installed&quot;
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(&quot;WinFax.SDKSend&quot;)



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 &quot;SetHold&quot; and sends the fax on the
' Appropriate Date and Time - Note it cannot be past date or time
.SetDate (&quot;10/08/98&quot;)
.SetTime (&quot;8:30:00&quot;)

'--- To:
.SetCountryCode (&quot;&quot;)
.SetAreaCode (strAreaCode)
.SetNumber (strPhNmb)

.SetTo (Me.to)
.SetCompany (Me.comp & &quot;&quot;)


'--- 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 (&quot;Larry's the Key&quot;) '<-- 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 & &quot;&quot;)
If Me.grpcoverpage < 3 Then
.SetCoverText (&quot;Test Cover Text&quot;) ' 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(&quot;Access.Application&quot;)
MSAccess.OpenCurrentDatabase &quot;c:\documents and Settings\thomas\desktop\saturn\saturn97.mdb&quot;
MSAccess.DoCmd.OpenReport &quot;faxemailcust&quot;, acViewNormal, , &quot;ID = &quot; & Me.faxid
'DoCmd.OpenReport &quot;faxemailcust&quot;, acViewNormal, , &quot;ID = &quot; & 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 &quot;Unable to >>reset<< the default printer.&quot;

End If
End If

ProcedureDone:
Exit Sub

HandleError:
MsgBox Err.Description, vbCritical, &quot;Error &quot; & Err & &quot; in ButtonFax1_Click&quot;
Resume ProcedureDone

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top