Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2016
    Posts
    3

    Unanswered: printing files from a list in Access

    Once more, I need your help. I fill a list box with Document names and the file path for each document (2 columns). The user checks a box for each document they want printed. The document could be Word, XL, Publisher or PDF. I have two questions. 1. is it possible to open any type of file or does Access only work with Word documents? 2. Is there a simple way to do it?

  2. #2
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,482
    Provided Answers: 11
    I have used this bit of code

    dont know where i found it

    Code:
    Declare Function apiShellExecute 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 Sub Print_This_File(ByVal strPathAndFilename As String)
         
        Call apiShellExecute(Application.hwnd, "print", strPathAndFilename, vbNullString, vbNullString, 0)
         
    End Sub
    just call the Print_This_File

    call Print_This_File("thefullpathandfilenametoprint")

    I Use it print PDF only but can't see why it wont work for doc files Dont know about xls file if they dont have a print range setup
    Last edited by myle; 02-08-17 at 14:08.
    hope this help

    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.
    DONT WORRY ABOUT THOSE WHO TALK BEHIND YOUR BACK
    THEY'RE BEHIND YOU FOR A REASON

  3. #3
    Join Date
    Sep 2016
    Posts
    3

    printing files from a list in access

    sorry for the delay but thank you for the code to print external files. it does work but does not do all I need it to do.

    Along with printing external files selected from a db form, I would like to set the number of copies, duplex and color printing if possible. I could use a dialog box, but there will be multiple files to be printed and I do not want to deal with the printer dialog box each file. I can set the number of copies wanted but cannot figure out the color or duplex settings. any help?

    Set WordDoc = WordObj.Documents.Open(ListDocNames.Column(1, 3))
    WordObj.ActiveDocument.PrintOut Copies:=numCopies
    WordDoc.Close SaveChanges:=wdDoNotSaveChanges

    I have also tried this code but cannot set duplex or color printing.
    Call apiShellExecute(Application.hWndAccessApp, "print", ListDocNames.Column(1, 6), vbNullString, vbNullString, 0)

  4. #4
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,482
    Provided Answers: 11
    Number of copies can be control with a for loop

    but the The Color and Duplex is a bit hard as they are printer function

    BUT how about this for and Idea

    why not Add the the Same Printer Many time and them set then up differance and then you can use code to select the right printing patten
    hope this help

    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.
    DONT WORRY ABOUT THOSE WHO TALK BEHIND YOUR BACK
    THEY'RE BEHIND YOU FOR A REASON

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •