Fax Software

Community Forums

  • This topic is empty.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #2618
    Anonymous
    Member

    I am attempting to send a merge document to multiple recipients defined by a text string on each page using SDKSend with Word 2K and NT 4.0 without diaplaying the Send dialog.

    The problem I have is that if the code is single-stepped, it works just fine, but if it runs without interruption, the Send dialog is displayed. I have tracked the problem to the destruction of the SDK Send object (Set = Nothing) in the routine. If that is removed, then everything works fine (but the object is not destroyed, which the documentation says is required for then next send). I have tried Send(1) and waiting fo an EntryID, but that never retruns ready (if I break out of it, the fax is sent properly). I have tried Enabling and Disabling background printing without any affect.

    Does anyone have any ideas?

    Thanks

    #4425
    Anonymous
    Inactive

    Hi Gary,
    can you post the portion of SDK code that you are using? Its probably something minor…

    #4426
    Anonymous
    Member

    Here’s the code i’m using. It is in a Word Macro, and i’m running NT4.0:

    Sub PrintPages()

    Dim WinFax as CSDKSend

    Application.ActivePrinter = “WinFax” ‘ Set WinFax Printer Name

    If WinFax Is Nothing Then
    Set WinFax = CreateObject(“WinFax.SDKSend8.0”)
    RetCode = WinFax.SetClientID(“Microsoft Word”)
    End If

    With WinFax
    ‘ Set Up Recipient

    .RemoveAllRecipients ‘ Make sure possible prior recipients are removed

    .SetAreaCode (“”)
    .SetCountryCode (“”)
    .SetDialPrefix (“714”)
    .SetNumber (“555-9029”)
    .SetExtension (“”)
    .SetTo (“Test Fax”) ‘ Person’s Name
    .SetTypeByName (“Fax”)
    RetCode = .AddRecipient()

    ‘ Set up the Fax

    RetCode = .SetPrintFromApp(1) ‘ Print using the print driver
    RetCode = .ShowSendScreen(0) ‘ Do not Display Send Screen
    RetCode = .SetDeleteAfterSend(1) ‘ Rewmove .fxs file after transmission
    RetCode = .Send(1) ‘ Execute the send We will wait for entry ID
    RetCode = .GetLastError()
    If RetCode <> 0 Then Stop
    Do Until WinFax.IsReadyToPrint() = 1 ‘ Wait for WinFax Driver Ready
    DoEvents
    Loop
    End With

    DoEvents

    Application.PrintOut FileName:=””, Range:=wdPrintRangeOfPages, Item:= _
    wdPrintDocumentContent, Copies:=1, Pages:=CStr(Pass + 1), PageType:= _
    wdPrintAllPages, Collate:=True, Background:=True, PrintToFile:=False, _
    PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
    PrintZoomPaperHeight:=0

    ‘ If these lines are in, it loops forever. When I break, it sends the fax. If I remove them, it works OK as long as the Set WinFax = Nothing is not executed. If the = Nothing is executed AFTER the status box comes up, then its OK.

    Do While WinFax.IsEntryIDReady(0) <> 1
    DoEvents
    Loop

    WinFax.Done

    ‘ Set WinFax = Nothing ‘ If it’s destroyed, then the send fails

    Exit Sub

    Thanks for your assistance.

    #4427
    Anonymous
    Member

    PS. The “Pass” Variable in the PrintOut is left over from a test to print multiple pages in a loop. If the Status box has not appeared and I attempt to send with the same send object, then I get an automation error.

    #4428
    Anonymous
    Inactive

    Gary,

    here are the changes I made, let me know if that helps. You mentioned that you tried turning off background printing, did you do this in your code? or in Word? if you did it in Word, that might be your problem since your code specifies to use Background printing. I’ve made that change and a slight change where ShowSendScreen is located (it is picky where this is located)
    (I have put *** where my changes are ***)
    If it still don’t work let me know.

    Sub PrintPages()

    Dim WinFax as CSDKSend

    Application.ActivePrinter = “WinFax” ‘ Set WinFax Printer Name

    If WinFax Is Nothing Then
    Set WinFax = CreateObject(“WinFax.SDKSend8.0”)
    RetCode = WinFax.SetClientID(“Microsoft Word”)
    End If

    With WinFax
    ‘ Set Up Recipient

    .RemoveAllRecipients ‘ Make sure possible prior recipients are removed

    .SetAreaCode (“”)
    .SetCountryCode (“”)
    .SetDialPrefix (“714”)
    .SetNumber (“555-9029”)
    .SetExtension (“”)
    .SetTo (“Test Fax”) ‘ Person’s Name
    .SetTypeByName (“Fax”)
    RetCode = .AddRecipient()

    ‘ Set up the Fax

    RetCode = .SetPrintFromApp(1) ‘ Print using the print driver

    RetCode = .SetDeleteAfterSend(1) ‘ Rewmove .fxs file after transmission
    RetCode = .Send(1) ‘ Execute the send We will wait for entry ID

    RetCode = .ShowSendScreen(0) ‘ Do not Display Send Screen
    ‘ **** Moved ShowSendScreen after Send(1)

    RetCode = .GetLastError()
    If RetCode <> 0 Then Stop
    Do Until WinFax.IsReadyToPrint() = 1 ‘ Wait for WinFax Driver Ready
    DoEvents
    Loop
    End With

    DoEvents

    ‘ *** changed background printing = False here ****

    Application.PrintOut FileName:=””, Range:=wdPrintRangeOfPages, Item:= _
    wdPrintDocumentContent, Copies:=1, Pages:=CStr(Pass + 1), PageType:= _
    wdPrintAllPages, Collate:=True, Background:=False, PrintToFile:=False, _
    PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
    PrintZoomPaperHeight:=0

    ‘ If these lines are in, it loops forever. When I break, it sends the fax. If I remove them, it works OK as long as the Set WinFax = Nothing is not executed. If the = Nothing is executed AFTER the status box comes up, then its OK.

    Do While WinFax.IsEntryIDReady(0) <> 1
    DoEvents
    Loop

    WinFax.Done

    ‘ *** set destroy object ***
    Set WinFax = Nothing ‘ If it’s destroyed, then the send fails

    Exit Sub

    #4429
    Anonymous
    Member

    Thanks VERY much. Sometimes another set of eyeballs will solve the problem. I HAD disabled background printing in the Options, but the PrintOut code was copied from a recorded macro and I did not notice the Background:=True. Changing that to False solved the problem. I would guess as long as the macro was running, Word would not start the background print, and therefore the EntryID would never get assigned. When the code breaks or is single stepped, Word starts the print and it works.

    Thanks greatly for the assist. Hopefully the code will help someone else with a similar problem.

    Gary

    #4430
    Anonymous
    Member

    The only thing to watch out for is if your PrintOut doesn’t actually print something (ie, the Page(s) being requested don’t exist). Word doesn’t seem to throw an error in that case and the IsEntryIDReady loop will run forever. Best approach would be to modify it as follows (also handle situation if WinFax Controller goes out to lunch:

    TheTime = Now()

    Do While WinFax.IsEntryIDReady(0) <> 1
    If Abs(DateDiff(“s”, TheTime, Now())) > 30 Then
    MsgBox “No EntryID after 30 seconds. Pass = ” & CStr(Pass)
    Exit Do
    End If
    DoEvents
    Loop

    You can forget about the Abs if you can remember (I can’t) which date comes first.

    Is there anything tricky if I am using WinFax in Client/Server mode?

    #4431
    Anonymous
    Inactive

    Hi Gary, glad that worked out for you. Yes, you are right there should be some sort of error handling to prevent your code from entering endless loop condition.

    In regards to a client/server setup, there is no difference in SDK code. (other than the fax is actually transmitted by the server PC, and not the client)

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.