Unanswered: How can I print an Access object to PDF from the command line?
I have a Microsoft Access query which I would like to be able to print to PDF from the command line. I already have the printer set up to print to a PDF file in the printer menu but right now it all has to be selected manually. And I've successfully used some command line switches with Access to print the basic query but the trouble is that I want to print the pivot chart view of the query, is this possible? I couldn't find any Access command line switches to do this and none of the third party applications are advanced enough to access the pivot chart view of the query, just the basic default view. Any ideas?
Printing to PDF is not a real problem, there are several free solutions you can download and use in your Access application. The question is: how do you reference an Access object from the command line?
Dim oAccess As Access.Application
' Start a new instance of Access for Automation:
oAccess = New Access.ApplicationClass()
' Open a database in exclusive mode:
oAccess.OpenCurrentDatabase(filepath:="c:\documents and settings\daniel.maher\Desktop\bugtrack.mdb", Exclusive:=True)
oAccess.DoCmd.OpenQuery(QueryName:="Report All Len Pivot Chart", View:=Access.AcView.acViewPivotChart)
oAccess.Printer = oAccess.Printers(6)
oAccess.Printer.Orientation = Access.AcPrintOrientation.acPRORLandscape
'MsgBox("printer: " + oAccess.Printer.DeviceName)
oAccess.DoCmd.PrintOut(Access.AcPrintRange.acPrintAll, Nothing, Nothing, Access.AcPrintQuality.acMedium, 1, 1)
This pops up a box asking for the filename for the PDF you wish to save to. I need to completely automate this application so do you know any way to have it automate the filename? Or use a default filename? Or are there any print to PDF applications which allow you to specify a default filename in a settings menu?