- This topic is empty.
-
AuthorPosts
-
September 24, 2001 at 6:19 pm #2618AnonymousMember
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
September 24, 2001 at 6:28 pm #4425AnonymousInactiveHi Gary,
can you post the portion of SDK code that you are using? Its probably something minor…September 24, 2001 at 6:40 pm #4426AnonymousMemberHere’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 IfWith 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 WithDoEvents
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
LoopWinFax.Done
‘ Set WinFax = Nothing ‘ If it’s destroyed, then the send fails
Exit Sub
Thanks for your assistance.
September 24, 2001 at 6:48 pm #4427AnonymousMemberPS. 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.
September 24, 2001 at 7:20 pm #4428AnonymousInactiveGary,
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 IfWith 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 IDRetCode = .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 WithDoEvents
‘ *** 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
LoopWinFax.Done
‘ *** set destroy object ***
Set WinFax = Nothing ‘ If it’s destroyed, then the send failsExit Sub
September 24, 2001 at 8:04 pm #4429AnonymousMemberThanks 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
September 24, 2001 at 8:52 pm #4430AnonymousMemberThe 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
LoopYou 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?
September 24, 2001 at 9:55 pm #4431AnonymousInactiveHi 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)
-
AuthorPosts
- You must be logged in to reply to this topic.