Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PDF Forms not printing all pages

Status
Not open for further replies.

cutestuff

Technical User
Sep 7, 2006
162
CA
hi,

I don't know if I'm in the right forum for this question.
I have an Access database that stores paths for PDF files stored in different folders. The user selects from combo boxes which files to batch print. I have been debugging for a few days now but still cannot figure out why not all pdf files are printing. If a folder contains more than 2 items only 1 or 2 print. :(

I created a DEBUG table to print the paths there to see if the error's in the loop but this seems to work perfectly. All the paths get written to the table accordingly. So there must be something wrong with printing the PDF files. ? But I cannot figure out what ? ?

Here is my code:
Code:
Private Sub cmdBatchPrint_Click()
 Dim tmpPath As String
 Dim filesys
 Dim varItem, tmp As Variant
 Dim stSQL As String 'for DEBUGGING purposes ONLY
 
    'Requery listbox
      listIDforBatch.Requery
      
    'Notify user that default printer is used for printout
    MsgBox "Note that the file(s) will print to your DEFAULT printer. If you would like to use another printer, please temporarily set your default to it.", vbOKCancel, "Info"
    
      For varItem = 0 To Me!listIDforBatch.ListCount - 1
    
        'Get path name for specific item
         tmpPath = DLookup("DocumentPath", "tblMainLog", "ID=" & listIDforBatch.ItemData(varItem))
    
                PrintDoc (tmpPath)
                
                'Insert paths to DEBUG table
                'stSQL = "INSERT INTO DEBUGGING(PathName) VALUES ('" & tmpPath & "')" 'FOR DEBUGGING PURPOSES ONLY
               ' CurrentDb.Execute (stSQL) 'FOR DEBUGGING PURPOSES ONLY
            
     Next varItem
         
End Sub

Here is the code behind printdoc:
Code:
Private Declare Function ShellExecute Lib "shell32.dll" _
      Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation _
      As String, ByVal lpFile As String, ByVal lpParameters As String, _
      ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long


   Public Function PrintDoc(ByVal DocFile As String) As Long
      ' Uses the "print" verb as defined in the registry
      PrintDoc = ShellExecute(0&, "print", DocFile, vbNullString, vbNullString, vbNormalFocus)
      
      End Function

Does anyone have any suggestion?

I appreciate any help.

Thanks so much in advance...
jen
 
Am I wrong or should there also be a End Function for ShellExecute?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top