I’m still pretty green when it comes to using other libraries and functions with Domino. It was recommended that I try to use a ShellAndWait routine for my project.
I need to print all PDF files from a particular FILE FOLDER. I’ve gotten pretty close with a ShellExecute Routine, but…
Not all my files are making it to the printer. I believe that is because previous files are not finishing before the next one is called to the printer.
Can anyone help me? I have attached my ShellExecute code to start with. Thank you in advance for any help.
Declare Function ShellExecute Lib “shell32.dll” Alias “ShellExecuteA” (Byval hwnd As Long, Byval lpszOp As String, Byval lpszFile As String, _
Byval lpszParams As String, Byval LpszDir As String, Byval FsShowCmd As Long) As Long
Declare Private Function GetDesktopWindow Lib “user32” () As Long
Private Const SW_HIDE = 0&
Sub Initialize
Dim s As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim odoc As NotesDocument
Dim mcount&
Dim folder$
Dim Scr_hDC&
Dim ret&
Dim file$
Dim filename$
Dim i&
Set db = s.CurrentDatabase
Set view = db.GetView("($Inbox)")
Set doc = view.GetFirstDocument
mcount = 0
folder = Format(Date,"mmm") & " " & Format(Date, "yy")
Do Until doc Is Nothing
mcount = mcount + 1
Call SaveAttachment (doc,mcount)
Call doc.PutInFolder( folder, True )
Call doc.RemoveFromFolder( "($Inbox)" )
Set doc = view.GetFirstDocument
Loop
Msgbox "Saved " & mcount & " documents.", 64, "Process Complete."
For i = 1 To mcount
Scr_hDC = GetDesktopWindow()
filename = "Images" & i & ".pdf"
ret = shellExecute(Scr_hDC, "print",filename ,Null ,"c:\temp\faxes\" ,SW_HIDE)
If ret <= 32 Then
Msgbox "An error occurs while printing!"
End If
Next i
Msgbox "Printed " & mcount & " documents.", 64, "Process Complete."
End Sub
Sub SaveAttachment(doc As NotesDocument,mcount As Long)
Dim item As NotesItem
Dim file$
Dim filename$
Dim obj As NotesEmbeddedObject
If doc.HasEmbedded Then
Forall it In doc.Items
If it.type=1084 Then 'attachment ($File)
file = it.values(0)
If file = "Images.PDF" Then
Set obj=doc.GetAttachment(it.values(0))
filename = "Images" & mcount & ".pdf"
Call obj.ExtractFile( "c:\temp\faxes\" & filename )
End If
End If
End Forall
End If
End Sub