• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 272
  • Last Modified:

VB program work with WinFax

Can a VB program send a document file to WinFax fax?
Moreover, can it set the WinFax time schedular also?


Thank you.
0
morye
Asked:
morye
  • 2
1 Solution
 
JasonRodriguesCommented:
Yes it can send a document file to winfax fax.

Winfax comes with installable macros for Word and Excel and you could make use of the code in these macros to automate the process.
0
 
moryeAuthor Commented:
Can I set the time schedular for fax?

For example :
During morning, I using the VB program to fax a doument at WinFax.
However, I want this file can be fax at night.

Is it work??

Thank you.
0
 
JasonRodriguesCommented:
I am putting the code below for you and you will see that you could either set the date & time or else you could set it to send it at the off peak time as configured in winfax. I hope this should help you

'Declarations
Public Declare Function RegOpenKey& Lib "ADVAPI32" Alias "RegOpenKeyA" (ByVal hkeyOpen&, ByVal szSubKey$, ByRef hkeyResult&)
Public Declare Function RegQueryValue& Lib "ADVAPI32" Alias "RegQueryValueExA" (ByVal hkey&, ByVal szValueName$, ByVal lReserved&, ByRef lType&, sValue As Any, ByRef lcbData&)

-------------------------------------------------------
'Code
Dim objWfx As Object
Set objWfx = CreateObject("WinFax.SDKSend8.0")
objWfx.SetClientID ("Client Name")
         
   
CurPrinter$ = Application.ActivePrinter
   
Port$ = GetWfxPort$
   
Application.ActivePrinter = sPrinterName & Port$

With objWfx
       .SetTo (ReceipientName)
       .SetNumber (FaxNumber)
       .SetAreaCode (AreaCode) ' if you want to specify the area code seprately
       .SetCountryCode (CountryCode) 'if you want to specify the country code seprately
       .SetTime (Format$(now, "HH:MM:SS"))
       .SetDate (Format$(now, "MM/DD/YY"))
       .SetCompany (CompanyName)
       .SetSubject (Subject)
       .AttachmentFile (FileName)
       .SetOffPeak (1) ' If you want to select off Peak
       .SetPriority (1)   '1. High, 2. Medium, 3. Low
       .Send (0)
End With

' Return printer to its original settings
If CurPrinter$ <> "" Then
       Application.ActivePrinter = CurPrinter$
End If

Set objWfx = Nothing
-----------------------------------------------------------------------------------------
'Functions
Function GetWfxPort$()
    On Error GoTo Errhandler
    Dim Version
    Version = SysVersions32()
   
    'If the Version is Windows 95/98 get reg entry from one location, if it is Windows NT
    'get the key from another location
 
    If Version = 1 Then
        WfxPort$ = Space(256)
        lResult& = RegOpenKey&(HLM, "System\CurrentControlSet\Control\Print\Printers\WinFax", hkeyWfx&)
        lResult& = RegQueryValue&(hkeyWfx&, "Port", 0&, lType&, ByVal 0&, lcbValue&)
        lResult& = RegQueryValue&(hkeyWfx&, "Port", 0&, lType&, ByVal WfxPort$, lcbValue&)
        WfxPort$ = Left$(WfxPort$, lcbValue& - 1)
        GetWfxPort$ = WfxPort$
    Else
        ' Windows NT/2000
        WfxPort$ = Space(256)
        lResult& = RegOpenKey&(HCU, "Software\Microsoft\Windows NT\CurrentVersion\Devices", hkeyWfx&)
        lResult& = RegQueryValue&(hkeyWfx&, sDriverName, 0&, lType&, ByVal 0&, lcbValue&)
        lResult& = RegQueryValue&(hkeyWfx&, sDriverName, 0&, lType&, ByVal WfxPort$, lcbValue&)
        WfxPort$ = Left$(WfxPort$, lcbValue& - 1)
        ' WfxPort$ = Right$(WfxPort$, 5)
        Position = InStr(1, WfxPort$, ",")
        WfxPort$ = Mid$(WfxPort$, Position + 1, Len(WfxPort$))
        GetWfxPort$ = WfxPort$
End If
Exit Function

Errhandler:
    'If the WinFax Printer entry is not found Stop
    ' the Macro and inform the user to
    ' re-install the printer driver
   
    MsgBox sError3 & Chr$(13) & Chr$(10) & sError4
    ' Error message that appears,
    ' "The printer Driver does not appear to be installed"
    ' + CRLF + "You must re-install the printer driver")
    End
End Function
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now