none
I want to export the current view to PDF but format to fit on a single page RRS feed

  • Question

  • I am currently using the following code to Export my active view to a pdf format.  I would like this to be formatted to a single page but it does not seem to work.  I looked everywhere - but MS Project VBA is not my usual domain...helping out a work colleague.

    Can anyone help me format the code so it works correctly?

    Sub ExportCurrentViewtoPDF()
    
    Dim tmp As String
    
    FilePageSetupPage PagesTall:=1
    tmp = ActiveProject.CurrentView
    DocumentExport FileName:="H:\" & tmp & ".pdf", FileType:=pjPDF
    
    End Sub



    Thursday, March 22, 2018 12:59 AM

All replies

  • Hi,

    I don't have MS Project. So, I tried to make Excel VBA code.
    This code is in a button [PDF_1page] on an Excel sheet.
     
    [exported PDF file]


    [Code]
    ' --- export to a PDF file with shrinking to 1 page
    Private Sub btn_PDF_1page_Click()
        ' --- decide PrintArea
        ActiveSheet.PageSetup.PrintArea = "B1:N100" ' -- << change this as you like
        ' --- PageSetup: FitToPagesWide=1, FitToPagesTall=1
        With ActiveSheet.PageSetup
            .Orientation = xlPortrait
            .PaperSize = xlPaperA4
            .Zoom = False
            .FitToPagesWide = 1
            .FitToPagesTall = 1
        End With
        ' --- export to PDF file: file name = C:\temp\WoWow.pdf
        ActiveSheet.ExportAsFixedFormat _
            Type:=xlTypePDF, _
            Filename:="C:\temp\WoWow.pdf", _
            IncludeDocProperties:=True, _
            IgnorePrintAreas:=False
        ' ---
        MsgBox "export to PDF completed !!"
    End Sub

    Regards,

    Ashidacchi >> http://hokusosha.com/

    • Edited by Ashidacchi Thursday, March 22, 2018 2:14 AM
    Thursday, March 22, 2018 2:11 AM
  • Export View,

    The subject of your post doesn't quite agree with the content. The subject talks about export to Excel while the content talks about export to PDF, two completely different things.

    At any rate, a document export is independent of print so there is no provision for pre-formatting the page setup when saving to PDF. You can adjust the pint setting once the document is in PDF but not as part of the export itself.

    Hope this helps.

    John

    Thursday, March 22, 2018 4:35 PM
  • My bad on the post heading - I did mean to specify, export to PDF...must have had a brain fart!

    So, what you are saying is that the only way to export to PDF is simply the current view and you cannot alter that automatically?

    I can manually do the export to fit on a single page...but when I tried to "record the steps" using the macro recorder, it did nothing :(

    Nothing I can do?

    Sunday, March 25, 2018 11:27 PM
  • I can also use:

    DocumentExport FileName:="H:\Test File TEST3.pdf"

    and this exports as 1 page wide, 3 pages tall...can I change this to A3 size, 1 page x 1 page using code?

    Sunday, March 25, 2018 11:40 PM
  • Hi,

    Have you read code I provided a few day ago.
    With ActiveSheet.PageSetup
            .Orientation = xlPortrait
            .PaperSize = xlPaperA4
            .Zoom = False
            .FitToPagesWide = 1
            .FitToPagesTall = 1
    End With
    This shows how to do.

    Regards,

    Ashidacchi -- http://hokusosha.com/

    Monday, March 26, 2018 12:12 AM
  • Ashidacchi,

    Unless I'm missing something you can use VBA to modify Page Setup and that will apply to the specific view in Project, but the user wants to use DocumentExport and that Method exports the document view without page setup parameters.

    I don't know if Adobe supports Visual Basic but if so it may be possible to incorporate page editing in some automated fashion perhaps as a separate routine called from the Project macro.

    John


    Monday, March 26, 2018 5:31 PM
  • Export view,

    Generally if a recorded macro gives no code when you stop recording and then view the macro, it means that process is not supported in VBA.

    So unfortunately, as far as I know the answer is still "no", you cannot pre-set page parameters for a PDF export of a Project document.

    John

    Monday, March 26, 2018 5:37 PM