?
Solved

Print first page of each file - PDF

Posted on 2012-03-23
8
Medium Priority
?
488 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
Industry Leaders: 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!

 
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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Suggested Courses

770 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