Print Function using winspool.drv affects other fields

I have a function that prints an embedded word document to our printer which has 4 trays. Depending on a particular variable, the document prints to different trays.

Since introducing the function, it is havng a knock-on affect on other simple functions, such as:

#######################################

'# Calculate options for CAT Codes

If source.editMode = True Then

Dim x As Integer

doc.sCatCodeChoice = ""

Dim lossType As String

lossType = doc.sLossType(0)

Dim sess As New notesSession		

Call getAdminDB( adminDB )

Dim catView As notesView

Set catView = adminDB.getView( "vM47" )

Dim catDocs As notesDocumentCollection

Set catDocs = catView.getAllDocumentsByKey( lossType, True )

Dim catDoc As notesDocument

Set catDoc = catDocs.getFirstDocument

While Not catDoc Is Nothing

    Dim lossDate As New notesDateTime( doc.dDateOfLoss(0) )

    Set startDate = New notesDateTime( catDoc.dStartDate(0) )

    Set endDate = New notesDateTime( catDoc.dEndDate(0) )		

    If lossDate.lsLocalTime => startDate.lsLocalTime Then

        If lossDate.lsLocalTime <= endDate.lsLocalTime Then

            If x=0 Then

                doc.sCatCodeChoice = catDoc.sName(0)	

                x=1

            Else

                doc.sCatCodeChoice = doc.sCatCodeChoice(0) & "," & catDoc.sName(0)

            End If

        End If

    End If

    Set catDoc = catDocs.getNextDocument( catDoc )

Wend

End If

#######################################

This is the function:

#######################################

Declare Private Function DeviceCapabilities Lib “winspool.drv” Alias “DeviceCapabilitiesA” _

(Byval lpDeviceName As String, Byval lpPort As String, Byval iIndex As Long, lpOutput As Any, Byval dev As Long) As Long

#######################################

This is called by:

#######################################

Public Function GetBinNumbers(app As Variant) As Variant

'Code adapted from Microsoft KB article Q194789

'HOWTO: Determine Available PaperBins with DeviceCapabilities API

Dim iBins As Long

Dim iBinArray() As Integer

Dim sPort As String

Dim sCurrentPrinter As String



'Get the printer & port name of the current printer

sPort = Trim$(Mid$(app.ActivePrinter, InStrRev(app.ActivePrinter, " ") + 1))

sCurrentPrinter = Trim$(Left$(app.ActivePrinter, Instr(app.ActivePrinter, " on ")))



'Find out how many printer bins there are

iBins = DeviceCapabilities(sCurrentPrinter, sPort, DC_BINS, Byval vbNullString, 0)



'Set the array of bin numbers to the right size

Redim iBinArray(0 To iBins - 1)



'Load the array with the bin numbers

iBins = DeviceCapabilities(sCurrentPrinter, sPort, DC_BINS, iBinArray(0), 0)



'Return the array to the calling routine

GetBinNumbers = iBinArray

End Function

#######################################

If I restart the client, the other functions work fine, until I call this print function. I cannot debug the functions that stop working, as this also seems to be affected.

Any advice/information at all would be appreciated.

Thanks,

Darren