Hi Everyone,
I am trying to make a macro that would open a report created, and print each individual sheet. In addition, every sheet has a PDF file linked to it which is saved in a cloud folder. So in essence, the report will print each page and the pdf linked to it which picks up from a query cell called [QuotPath].
This is my macro:
Private Sub PrintProjectDetails_Click()
'' please note you have to install pdf reader application in your system for this code to work
Dim rst As DAO.Recordset
Dim strSQL As String
Dim mypath As String
Dim myID As Long
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "078ProjectDetails" '' // this is the report name
strSQL = "select * from ProjectDetailQueries10" '' // this is the query name
Set rst = CurrentDb.OpenRecordset(strSQL)
rst.MoveFirst
Do While Not rst.EOF
mypath = rst![QuotPath]
stLinkCriteria = "[BudgetID]=" & rst![BudgetID] '' // filter by the budget id column name
CreateObject("Shell.Application").NameSpace(0).Par seName(mypath).InvokeVerb ("Print") '' // this is to print pdf document
DoCmd.OpenReport stDocName, acNormal, , stLinkCriteria ' // this is to print report
rst.MoveNext
Loop
rst.Close
MsgBox ("done !")
End Sub
Could you please help??