423,688 Members | 1,894 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,688 IT Pros & Developers. It's quick & easy.

could i print an external pdf file in a database form ??

P: 18
i had a pdf file could i insert a button on clicking it print this file ?

thanks in advance
Sep 23 '17 #1

✓ answered by ADezii

  1. Copy-N-Paste the following API and Constant Declarations into a Standard Code Module. Depending on your System, you may need to remove the PtrSafe Qualifier.
    Expand|Select|Wrap|Line Numbers
    1. Public Const SW_SHOWMINNOACTIVE = 7
    2.  
    3. Public Declare PtrSafe Function ShellExecute Lib "Shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, _
    4.                        ByVal lpOperation As String, _
    5.                        ByVal lpFile As String, _
    6.                        ByVal lpParameters As String, _
    7.                        ByVal lpDirectory As String, _
    8.                        ByVal nShowCmd As Long) As Long
  2. Copy-N-Paste the following Code to wherever appropriate. You will need to change the Value of the Constant conFilePath to one of your own choosing.
    Expand|Select|Wrap|Line Numbers
    1. Dim lngRetVal As Variant
    2. Dim strFolder As String
    3.  
    4. '****************** USER DEFINED ******************
    5. Const conFilePath As String = "C:\Test\Test.pdf"
    6. '**************************************************
    7.  
    8. 'Extract the Working Folder
    9. strFolder = Left$(conFilePath, InStrRev(conFilePath, "\") - 1)
    10.  
    11. lngRetVal = ShellExecute(0, "Print", conFilePath, "", strFolder, SW_SHOWMINNOACTIVE)
  3. The File defined in the Constant conFilePath will automatically be Printed. It will be printed by the Default Application listed in your Registry for *.pdf Files.
  4. Good Luck with your Project.

Share this Question
Share on Google+
7 Replies


PhilOfWalton
Expert 100+
P: 1,373
I think you would need to store the path to the PDF in your database.

Phil
Sep 23 '17 #2

NeoPa
Expert Mod 15k+
P: 31,084
I don't believe Access has the native capability to print out a PDF file. However, there may well be an opportunity, using Application Automation, to get Adobe Reader to print it for you.

That's something you'd need help from elsewhere on. The basics of using Application Automation are covered in the linked article but I doubt we can help on the specifics of automating Adobe Reader.
Sep 23 '17 #3

ADezii
Expert 5K+
P: 8,585
As long as you have the Absolute Path, you can Print the *.pdf File with a Single Click using the ShellExecute() API Function. If you interested, I'll post the Code for you.
Sep 23 '17 #4

P: 18
fine could you give me the code plzz ??
Sep 24 '17 #5

ADezii
Expert 5K+
P: 8,585
  1. Copy-N-Paste the following API and Constant Declarations into a Standard Code Module. Depending on your System, you may need to remove the PtrSafe Qualifier.
    Expand|Select|Wrap|Line Numbers
    1. Public Const SW_SHOWMINNOACTIVE = 7
    2.  
    3. Public Declare PtrSafe Function ShellExecute Lib "Shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, _
    4.                        ByVal lpOperation As String, _
    5.                        ByVal lpFile As String, _
    6.                        ByVal lpParameters As String, _
    7.                        ByVal lpDirectory As String, _
    8.                        ByVal nShowCmd As Long) As Long
  2. Copy-N-Paste the following Code to wherever appropriate. You will need to change the Value of the Constant conFilePath to one of your own choosing.
    Expand|Select|Wrap|Line Numbers
    1. Dim lngRetVal As Variant
    2. Dim strFolder As String
    3.  
    4. '****************** USER DEFINED ******************
    5. Const conFilePath As String = "C:\Test\Test.pdf"
    6. '**************************************************
    7.  
    8. 'Extract the Working Folder
    9. strFolder = Left$(conFilePath, InStrRev(conFilePath, "\") - 1)
    10.  
    11. lngRetVal = ShellExecute(0, "Print", conFilePath, "", strFolder, SW_SHOWMINNOACTIVE)
  3. The File defined in the Constant conFilePath will automatically be Printed. It will be printed by the Default Application listed in your Registry for *.pdf Files.
  4. Good Luck with your Project.
Sep 24 '17 #6

NeoPa
Expert Mod 15k+
P: 31,084
Nice one ADezii. That's a better solution.
Sep 24 '17 #7

ADezii
Expert 5K+
P: 8,585
Nice one ADezii. That's a better solution.
Thanks NeoPa, I use ShellExecute()quite often and find it to be a very versatile API Function.
Sep 24 '17 #8

Post your reply

Sign in to post your reply or Sign up for a free account.