{"id":6,"date":"2010-11-26T21:56:41","date_gmt":"2010-11-26T21:56:41","guid":{"rendered":"http:\/\/mariaevert.dk\/VBA\/?p=6"},"modified":"2010-11-29T12:27:28","modified_gmt":"2010-11-29T11:27:28","slug":"my-second-blog","status":"publish","type":"post","link":"https:\/\/mariaevert.dk\/vba\/?p=6","title":{"rendered":"VBA &#8211; Define PageSetup (PaperSize, Orientation, etc.) and Print Excel Sheet"},"content":{"rendered":"<p>This posts explains how to print an Excel page using VBA and <code>PrintOut<\/code>. Normally, you will want to define the <code>PageSetup <\/code>first, in order to make sure that the right printer, the right paper size (fx A4), orientation (landscape or portrait), etc. is selected. <\/p>\n<p>Step 1: Define <code>PageSetup<\/code>. <\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n\r\nWith Worksheets(&quot;MyPage&quot;).PageSetup\r\n     .Orientation = xlPortrait\r\n     .Zoom = False\r\n     .FitToPagesWide = 1\r\n     .FitToPagesTall = 1\r\n     .PaperSize = xlPaperA4\r\nEnd With\r\n <\/pre>\n<p>It&#8217;s important to add the <code>Zoom<\/code> property in adition to the <code>FitTo...<\/code> properties, as you can otherwise not be sure that the printing in fact is restricted to 1&#215;1 page. <\/p>\n<p>Step 2: Print the page. <\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nSheets(&quot;MyPage&quot;).PrintOut Copies:=1, Collate:=True\r\n <\/pre>\n<p>And that&#8217;s it!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This posts explains how to print an Excel page using VBA and PrintOut. Normally, you will want to define the PageSetup first, in order to make sure that the right printer, the right paper size (fx A4), orientation (landscape or portrait), etc. is selected. Step 1: Define PageSetup. It&#8217;s important to add the Zoom property [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/mariaevert.dk\/vba\/index.php?rest_route=\/wp\/v2\/posts\/6"}],"collection":[{"href":"https:\/\/mariaevert.dk\/vba\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mariaevert.dk\/vba\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mariaevert.dk\/vba\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mariaevert.dk\/vba\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6"}],"version-history":[{"count":8,"href":"https:\/\/mariaevert.dk\/vba\/index.php?rest_route=\/wp\/v2\/posts\/6\/revisions"}],"predecessor-version":[{"id":41,"href":"https:\/\/mariaevert.dk\/vba\/index.php?rest_route=\/wp\/v2\/posts\/6\/revisions\/41"}],"wp:attachment":[{"href":"https:\/\/mariaevert.dk\/vba\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mariaevert.dk\/vba\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mariaevert.dk\/vba\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}