Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Print first page of each file - PDF

Posted on 2012-03-23
8
Medium Priority
?
490 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
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

636 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