Solved

Print first page of each file - PDF

Posted on 2012-03-23
8
465 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
  • 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
 
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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

746 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now