I am trying to export excel worksheets into pdf. Is there any way by which I can set the pdf property to fit to visible
using VBA.
Thanks
Below is the code snippet which I am using
With wksSalesAndQuotaScoreCard
'.PageSetup.LeftMargin=Application.InchesToPoints(0.7)
.PageSetup.LeftMargin = Application.InchesToPoints(0.7)
.PageSetup.RightMargin = Application.InchesToPoints(0.7)
.PageSetup.TopMargin = Application.InchesToPoints(0.75)
.PageSetup.BottomMargin = Application.InchesToPoints(0.75)
.PageSetup.HeaderMargin = Application.InchesToPoints(0.3)
.PageSetup.Orientation = xlLandscape
.PageSetup.PrintTitleRows = "_SalesandQuotaScoreCardView"
.PageSetup.CenterHorizontally = True
.PageSetup.Order = xlDownThenOver
.PageSetup.FitToPagesWide = 1
''.PageSetup.Zoom = 50
Set rngSalesAndQuotaView = Range(.Shapes("_SalesandQuotaViewFrame").TopLeftCell.Offset(0, -1), .Shapes("_SalesandQuotaViewFrame").BottomRightCell.Offset(1, 0))
rngSalesAndQuotaView.Select
End With
wksScoreCardPayoutView.Select
wksSalesAndQuotaScoreCard.Select False
Selection.ExportAsFixedFormat xlTypePDF, IncludeDocProperties:=True, openafterpublish:=True
wksCustomizeScoreCard.Activate
Adobe has a set of codes you can use when opening a document:
http://partners.adobe.com/public/developer/en/acrobat/PDFOpenParameters.pdf
Be advised, these only work with the approved Adobe Reader and not all PDF readers will accept these commands.
You might have to have Acrobat to set the conditions manually per this answer on the Adobe Help Forums:
Regarding the OP: "How can I set the default to open all PDF's at 100% zoom magnification?"
With Acrobat Pro, run a Batch Process (Sequence)/Action to run the "Open Options" sequence. This sequence permits setting the values for all items under the Initial View tab of PDFs' Document Properties.
Regarding a PDF's Document Properties > Initial View: Visit an open PDF's Document Properties (Ctrl+D, Cmd+D). Go to the Initial View tab. The top pane (Layout and Magnification) permits configuration of:
Navigation tab: Page Only | Bookmarks Panel and Page | Pages Panel and Page | Attachments Panel and Page | Layers Panel and Page Page Layout: Default | Single Page | Single Page Continuous | Two-Up (Facing) | Two-Up (Cover Page) | Two-Up Continuous (Cover Page) Magnification: Default | Actual Size | Fit Page | Fit Width | Fit Height | Fit Visible | Magnification percentages (25% to 6400%)
Configuration settings other than "Default" dictate how the PDF is viewed initially.
The settings for all values in all panes in the Initial View may be established for one or many PDFs by use of a Batch Sequence/Action (Acrobat Pro required).
This functionality is utilized in an enterprise environment where large document collections are deployed in a LAN/WAN "eLibrary" to provide a consistent initial view to end-users.
It also provides a content author a mechanism for establishing the initial view for their deployed content (such as PDF document collections distributed on optical storage media).
As to the typical default Initial View for a created PDF: When a PDF is created via Acrobat the PDF document's default Initial View for Layout and Magnification is: --| Navigation: Page Only --| Page layout: Default --| Magnification: Default --| Open to page: 1
Regarding the Open Parameters document — While this document does provide a few command line options the document's primary focus is the use of a URL to open a URL's targeted PDF's initially opening.
Worth noting is that the document is specific for URLs and not applicable to UNC links (links with a LAN/WAN).
If I have understood your request, you need your print area (because exporting to PDF it's like printing) to adjusted both on width and height. You have the .PageSetup.FitToPagesWide = 1
statement, now you need also .FitToPagesTall = 1
, so your code will look like:
With wksSalesAndQuotaScoreCard
'.PageSetup.LeftMargin=Application.InchesToPoints(0.7)
.PageSetup.LeftMargin = Application.InchesToPoints(0.7)
.PageSetup.RightMargin = Application.InchesToPoints(0.7)
.PageSetup.TopMargin = Application.InchesToPoints(0.75)
.PageSetup.BottomMargin = Application.InchesToPoints(0.75)
.PageSetup.HeaderMargin = Application.InchesToPoints(0.3)
.PageSetup.Orientation = xlLandscape
.PageSetup.PrintTitleRows = "_SalesandQuotaScoreCardView"
.PageSetup.CenterHorizontally = True
.PageSetup.Order = xlDownThenOver
.PageSetup.FitToPagesWide = 1
.FitToPagesTall = 1
''.PageSetup.Zoom = 50
Set rngSalesAndQuotaView = Range(.Shapes("_SalesandQuotaViewFrame").TopLeftCell.Offset(0, -1), .Shapes("_SalesandQuotaViewFrame").BottomRightCell.Offset(1, 0))
rngSalesAndQuotaView.Select
End With
If this is not the solution, please explain what is this fittovisible
for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With