[AccessD] OT: TS and Automation

Henry Simpson hsimpson88 at hotmail.com
Thu Jun 26 14:52:51 CDT 2003


That will take a bit of work.  I'll have to figure out how to retrieve a 
handle to a printer and identify specific print jobs etc.

I'd been looking at:

http://www.mvps.org/word/FAQs/MacrosVBA/WaitForPrint.htm

option #2 which tells me to poll on an interval the Word object 
BackgroundPrintingStatus which returns the number of print jobs in the 
background printing queue and that would be adequate except:

'Generally, option#1 is safer, because Word can sometimes get a bit confused 
if asked to background print too many documents at once."

And option #1 is to use ActiveDocument.Printout Background:=False which is 
supposed to pause automation driver code until Word completes printing.  
Unfortunately, the code appears to run over this line without hesitation.  
Even if the jobs are enqueued, it appears as though the number of jobs alone 
may overwhelm the server.  If either approach can be made to work reliably I 
will safely be able to close Word or it's documents as they are finished and 
not overrun the server.

I suppose I'll look at the api calls if a test run while most of the staff 
are out this long weekend flops.  Thanks.

Hen



>From: MartyConnelly <martyconnelly at shaw.ca>
>Reply-To: accessd at databaseadvisors.com
>To: accessd at databaseadvisors.com
>Subject: Re: [AccessD] OT: TS and Automation
>Date: Thu, 26 Jun 2003 12:02:27 -0700
>
>You might be able to interrogate the printer statuses via winspool.drv 
>depending on how hard they have locked it down.
>
>Private Declare Function GetJob Lib "winspool.drv" Alias "GetJobA" _
>                          (ByVal hPrinter As Long, _
>                           ByVal JobId As Long, _
>                           ByVal Level As Long, _
>                           buffer As Long, _
>                           ByVal pbSize As Long, _
>                           pbSizeNeeded As Long) As Long
>
>Private Declare Function SetJob Lib "winspool.drv" Alias _
>                     "SetJobA" (ByVal hPrinter As Long, _
>                                ByVal JobId As Long, _
>                                ByVal Level As Long, _
>                                pJob As Long, _
>                                ByVal Command As Long) As Long
>
>
>Public Enum PrintJobStatuses
>    JOB_STATUS_PAUSED = &H1
>    JOB_STATUS_ERROR = &H2
>    JOB_STATUS_DELETING = &H4
>    JOB_STATUS_SPOOLING = &H8
>    JOB_STATUS_PRINTING = &H10
>    JOB_STATUS_OFFLINE = &H20
>    JOB_STATUS_PAPEROUT = &H40
>    JOB_STATUS_PRINTER = &H80
>    JOB_STATUS_DELETED = &H100
>    JOB_STATUS_BLOCKED_DEVICEQUEUE = &H200
>    JOB_STATUS_USER_INTERVENTION = &H400
>    JOB_STATUS_RESTART = &H800
>End Enum
>
>Private Type SYSTEMTIME
>    wYear As Integer
>    wMonth As Integer
>    wDayOfWeek As Integer
>    wDay As Integer
>    wHour As Integer
>    wMinute As Integer
>    wSecond As Integer
>    wMilliseconds As Integer
>End Type
>
>Private Type JOB_INFO_1
>    JobId As Long
>    lpPrinterName As String
>    lpMachinename As String
>    lpUserName As String
>    lpDocumentName As String
>    lpDataType As String
>    lpStatus As String
>    Status As PrintJobStatuses
>    Priority As Long
>    Position As Long
>    TotalPages As Long
>    PagesPrinted As Long
>    Submitted As SYSTEMTIME
>End Type
>
>Private Type JOB_INFO_2
>    JobId As Long
>    lpPrinterName As String
>    lpMachinename As String
>    lpUserName As String
>    lpDocumentName As String
>    lpNotifyName As String
>    lpDataType As String
>    lpPrintProcessor As String
>    lpParameters As String
>    lpDriverName As String
>    lpDevMode As Long 'Pointer to DevMode
>    lpStatus As String
>    lpSecurityDescriptor As Long 'Pointer to SECURITY_DESCRIPTOR
>    Status As PrintJobStatuses
>    Priority As Long
>    Position As Long
>    StartTime As Long
>    UntilTime As Long
>    TotalPages As Long
>    JobSize As Long
>    Submitted As SYSTEMTIME
>    time As Long
>    PagesPrinted As Long
>End Type
>
>'\\ Included in WINNT4 and beyond
>Private Type JOB_INFO_3
>    JobId As Long
>    NextJobId As Long
>    Reserved As Long 'must be set to zero
>End Type
>
>Henry Simpson wrote:
>
>>I don't really know this outfit's architecture.  They have a file server 
>>and a terminal server, a good number of Win CE terminals at the site plus 
>>off site terminals and three Lexmark laser printers with NICs connected to 
>>the LAN.  There is also a single workstation running Win2k that was idle 
>>at the time as well as two or three Win2k laptops which were doing 
>>whatever they do.  I have no priveleges at this security conscious site so 
>>do not have access to the Pinters in Win Explorer for properites, print 
>>queues, control panel or any other information.  They have had spontaneous 
>>Terminal server reboots when large graphics files were sent to the color 
>>laser in high resolution modes and it has also rebooted once when it was 
>>sent a batch of 80 Word documents in a quick loop.  These spontaneous 
>>reboots have only started since they switched to a thin client 
>>environment.  The resource crash was clearly instigated by the multiple 
>>Word instances since clearing them allowed users to continue working for a 
>>time.  There is no doubt that printing has been an issue in recent months.
>>
>>Hen
>>
>>
>>>From: Drew Wutka <DWUTKA at marlow.com>
>>>Reply-To: accessd at databaseadvisors.com
>>>To: "'accessd at databaseadvisors.com'" <accessd at databaseadvisors.com>
>>>Subject: RE: [AccessD] OT: TS and Automation
>>>Date: Thu, 26 Jun 2003 11:41:24 -0500
>>>
>>>Where was the printer running from, was it on a print server.  There is a
>>>known print server bug between NT 4.0 print servers and Windows 2000
>>>machines.  It causes a massive amount of connections, which exceeds NT 
>>>4.0's
>>>limit.....which doesn't really show up as memory or CPU resources, 
>>>however,
>>>it completely blocks access to the print server (so if it is also a PDC 
>>>or
>>>BDC, you just locked a lot of people out of the network)
>>>
>>>Drew
>>>
>>>-----Original Message-----
>>>From: Henry Simpson [mailto:hsimpson88 at hotmail.com]
>>>Sent: Thursday, June 26, 2003 11:24 AM
>>>To: accessd at databaseadvisors.com
>>>Subject: [AccessD] OT: TS and Automation
>>>
>>>
>>>Yesterday some users ran some automation code that creates Word instances 
>>>in
>>>
>>>a loop and kills them after printing but it turns out that the printer 
>>>was
>>>so slow that the number or Word instances increased to the point that the 
>>>NT
>>>
>>>Terminal Server ran out of some kinds of resources and started giving
>>>spurious error messages about not finding a printer, being unable to 
>>>install
>>>
>>>a printer and then User32.dll errors and path not found errors.  One user
>>>was eventually unable to open any applications except that which was 
>>>already
>>>
>>>open.  An admin cleared the excess Word instances, as many as 18 that 
>>>outran
>>>
>>>the printer, and then the user was able to work for a while.  Ultimately,
>>>afflicted users logged right out and back in again as a precaution.
>>>
>>>After that, more and more users began to have problems and ultimately, no
>>>one was able to log in to the server.  Before it all completely failed, 
>>>an
>>>admin took a look at resource and there was plenty of memory and low
>>>processor usage and all unnecessary instances of applications were 
>>>cleared
>>>yet every single person started getting the user32.dll error and, after
>>>logging out, was unable to log back in due to a time out even though the
>>>Terminal Server was on a local LAN.  The admin was able to see that all
>>>users were out and no user applications were running but he also got a
>>>user32.dll error from which there was no recovery.  An attempt to restart
>>>from Task Manager gave the same user32.dll errors and after 45 minutes of
>>>recovery attempts, it was finally decided to interrupt the power off the
>>>server.
>>>
>>>Ultimately Access automation code took full responsibility for the fiasco
>>>and the Terminal Server was blameless.
>>>
>>>I'm not desperate for solutions as code can revert to a single Word 
>>>instance
>>>
>>>- multi Document with 20 second time delay approach that worked in the 
>>>past.
>>>
>>>   I could use help with code that pauses the Access automation while it
>>>waits for a print job to complete.  So far I've dabbled with
>>>
>>>           objWord.Options.PrintBackground = False
>>>           objDoc.PrintOut Background:=False
>>>
>>>
>>>What gets me is the Admin view that the Access code is responsible for 
>>>their
>>>
>>>inability to release resources that were some how used but didn't show up 
>>>in
>>>
>>>any resource monitors or error logging.
>>>
>>>Hen
>>>
>>>_________________________________________________________________
>>>Tired of spam? Get advanced junk mail protection with MSN 8.
>>>http://join.msn.com/?page=features/junkmail
>>>
>>>_______________________________________________
>>>AccessD mailing list
>>>AccessD at databaseadvisors.com
>>>http://databaseadvisors.com/mailman/listinfo/accessd
>>>Website: http://www.databaseadvisors.com
>>>_______________________________________________
>>>AccessD mailing list
>>>AccessD at databaseadvisors.com
>>>http://databaseadvisors.com/mailman/listinfo/accessd
>>>Website: http://www.databaseadvisors.com
>>
>>
>>_________________________________________________________________
>>The new MSN 8: advanced junk mail protection and 2 months FREE*  
>>http://join.msn.com/?page=features/junkmail
>>
>>_______________________________________________
>>AccessD mailing list
>>AccessD at databaseadvisors.com
>>http://databaseadvisors.com/mailman/listinfo/accessd
>>Website: http://www.databaseadvisors.com
>>
>
>
>_______________________________________________
>AccessD mailing list
>AccessD at databaseadvisors.com
>http://databaseadvisors.com/mailman/listinfo/accessd
>Website: http://www.databaseadvisors.com

_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*.  
http://join.msn.com/?page=features/featuredemail



More information about the AccessD mailing list