Print of multiple documents of diffent type from access

  • Thread starter Thread starter Sogge
  • Start date Start date
S

Sogge

Hi' Everyone,

I've got a table containing 10 records with 1 field, each field
contains a full pathname of a "document" (i.e. Word, Excel, PDF, txt
etc.). How can I print each of theese "documents"?

Best regards

Sogge
 
On Thu, 10 Apr 2008 05:40:02 -0700 (PDT), Sogge <[email protected]>
wrote:

You can use the ShellExecute API with the "print" verb. This is what
Windows itself uses when you drop a document on a printer icon.
Windows will then invoke the registered application for the file
extension to actually print the document.

-Tom.
 
Hi' Tom,

Thanks a lot for you're reply - this is exactly what I'm looking for.
However I'm not that familiar with "ShellExecute API". Could you
please post a brief code-example of how to print one single document -
i.e. "c:\Word\myworddoc.doc".

Best regards

Sogge
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
Hi' everyone,

I found out myself how to declare use "ShellExecute API" function in
Win Xp PRO to print a document. Here is the testet code - check out
the TstPrint rutine in the bottom:

'**************************************************************************************
Option Compare Database
'***************************START Declare
ShellExecute*************************
'''''
'************ Code Start **********
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
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

'***App Window Constants***
Public Const WIN_NORMAL = 1 'Open Normal
Public Const WIN_MAX = 3 'Open Maximized
Public Const WIN_MIN = 2 'Open Minimized

'***Error Codes***
Public Const ERROR_SUCCESS = 32&
Public Const ERROR_NO_ASSOC = 31&
Public Const ERROR_OUT_OF_MEM = 0&
Public Const ERROR_FILE_NOT_FOUND = 2&
Public Const ERROR_PATH_NOT_FOUND = 3&
Public Const ERROR_BAD_FORMAT = 11&
'''''
'***************************END Declare
ShellExecute*************************
'''''

Public Sub TstPrint()
Dim ret As Variant
ret = ShellExecute(0, "print", "d:\Test.doc", vbNullString, 0,
WIN_MIN)
End Sub
 
Back
Top