Solved

Print first page of each file - PDF

Posted on 2012-03-23
8
479 Views
Last Modified: 2012-03-30
I have a table with the full paths of several files (that happen to be PDFs).

I have this code that will print all the files but I would like to modify/replace it with code that will limit the print to the first page of each file:
Function PrintDigSafePackage()

Dim cFile As String
Dim RetVal As Long
Dim cAction
Dim cPrinterName

cAction = "printto"

cPrinterName = "DPW_MGT - Ricoh MP6000"

' Get files to print
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("select * from DigSafePackagePrint order by Address, Sort")

'Print Files

Do While rs.EOF = False
   
    If Len(Dir(rs("FilePath"))) Then
    cFile = rs!FilePath
    RetVal = ShellExecute(0, cAction, cFile, cPrinterName, "", 1)
    
    End If
    cFile = ""
    rs.MoveNext
Loop
rs.close
Set rs = Nothing


End Function

Open in new window


Please help.

Jeff
0
Comment
Question by:wellesleydpw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37757056
This may not be easy.

ShellExecute does not have any parameters to set the "page" to print.

You can probably "Open" the file instead, then add in a call to the printer Object and set it to print Page 1.

Either that or use "SendKeys" (not recommended) to "Manually" set this up.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37757082
I am sure an expert will be along who can go into more detail about manipulating the Printer settings.

Another "Option" ( I use that term lightly) to get this going currently, might be to simply create a second set of pdfs that only contain "Page 1"...?
0
 

Author Comment

by:wellesleydpw
ID: 37776065
Thanks Boag2000,
No one else has responded yet, can you tell me where to look into your Open and Call solution?
Jeff
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37776795
In your shellExecute code you would change cAction to "Open"
Then see the code here...:
http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=101
0
 

Author Comment

by:wellesleydpw
ID: 37783062
I've got this working using Acroexch which I hadn't known about previously:

Function PrintDigSafePackage()
Dim App As Object
Dim AVDoc As Object
Dim rs As DAO.Recordset

Dim retcd As Integer
Dim cFile As String

Set App = CreateObject("Acroexch.app")
Set AVDoc = CreateObject("AcroExch.AVDoc")
Set rs = CurrentDb.OpenRecordset("select * from DigSafePackagePrint order by Address, Sort")

' Cycle through files to print
Do While rs.EOF = False
   
    If Len(Dir(rs("FilePath"))) Then
    cFile = rs!FilePath
 
    'Open File
    retcd = AVDoc.Open(cFile, "Title")
    'Print first page only (i.e. page 0)
    retcd = AVDoc.PrintPages(0, 0, 0, 1, 1)
    
    AVDoc.close (1)
    
    End If
    cFile = ""
    rs.MoveNext
Loop
rs.close

Set rs = Nothing
Set AVDoc = Nothing
End Function

Open in new window


Hope this helps someone in the future.
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
ID: 37783381
Is that for the Full version of Adobe Acrobat..?

Sorry, my posts were presuming that the user would only have the reader...
just worth noting...

Great, you can accept your own post as the solution...

;-)

JeffCoachman
0
 

Author Closing Comment

by:wellesleydpw
ID: 37786032
I do have the full version (Adobe X Pro) and honestly, I don't know how to tell if the code requires it or not.  Because you're the only one who assisted and I did need to open first, I'm giving you the points.  Thanks for your help.
Jeff
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37787563
Nope, ...you answered your own question, so that is the post you should accept.
If you accept my post, it is marked as the "Solution".

This will confuse other member searching here for the same issue.
They will wonder how my post is a "Solution"

;-)

Please click the "Request Attention" link and ask that your post: (37783062) be changed to the accepted solution.

;-)

Enjoy the weekend...

;-)

Jeff
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Split on ASP 8 45
Looking for advice on how to develop a project database 2 39
vb6 Where condition on dbo 2 25
VB.NET Parsing UDP Bytes 13 21
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

742 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question