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.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.
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.
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

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&)

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
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$
        ' 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

    '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 Function

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.