Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2009
    Posts
    2

    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?

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    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?

    Have a nice day!

  3. #3
    Join Date
    Apr 2009
    Posts
    2
    Well here is what I have so far:

    Code:
    Imports Microsoft.Office.Interop
    
    Module Module1
        Sub main()
            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)
    
        End Sub
    
    End Module
    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •