none
Insert the range into VBA RRS feed

  • Question

  • I have the code below and it works fine.  I would like to convert a specific range from both worksheets so that when it converts to PDF only the selected ranges are shown. How do I add the ranges into the VBA code:

    Sub macro_PDF()
    With Worksheets(Array("Project Scope", "Scorecard Dashboard")).Select
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:=mypath1, _
    Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
    OpenAfterPublish:=True
    End With
    End Sub

    Friday, April 26, 2013 1:10 PM

Answers

All replies

  • When using ActiveSheet.ExportAsFixedFormat, you can't specify a range.

    You'd have to copy the ranges to a single sheet, then convert that sheet to PDF.


    Regards, Hans Vogelaar

    Friday, April 26, 2013 1:26 PM
  • Can I use the same code twice using  a single button click. Then both ranges will be used to convert to one single PDF? This was my original code:

    With Sheets("Project Scope").Range("PScope")
    .ExportAsFixedFormat Type:=xlTypePDF, Filename:=mypath1, _
    Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
    OpenAfterPublish:=True
    End With

    Friday, April 26, 2013 2:13 PM
  • If you use the same code twice, the second PDF file will overwrite the first one.

    Regards, Hans Vogelaar

    Friday, April 26, 2013 7:24 PM
  • If you use the ranges to set the print area, then change  IgnorePrintAreas:=False to  IgnorePrintAreas:=True, does it work (assuming different file names used!)?

    Rod Gill

    The one and only Project VBA Book

    Rod Gill Project Management

    • Proposed as answer by Shasur Sunday, April 28, 2013 6:01 AM
    • Unproposed as answer by Paida90 Monday, April 29, 2013 9:10 AM
    • Marked as answer by Paida90 Monday, April 29, 2013 9:10 AM
    Saturday, April 27, 2013 12:01 AM