{"id":66563,"date":"2006-08-31T15:19:00","date_gmt":"2006-08-31T15:19:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2006\/08\/31\/how-can-i-set-the-document-orientation-in-microsoft-word-to-landscape\/"},"modified":"2006-08-31T15:19:00","modified_gmt":"2006-08-31T15:19:00","slug":"how-can-i-set-the-document-orientation-in-microsoft-word-to-landscape","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/how-can-i-set-the-document-orientation-in-microsoft-word-to-landscape\/","title":{"rendered":"How Can I Set the Document Orientation in Microsoft Word to Landscape?"},"content":{"rendered":"<p><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Question\" border=\"0\" alt=\"Hey, Scripting Guy! Question\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" width=\"34\" height=\"34\"> \n<P>Hey, Scripting Guy! How can I set the document orientation in Microsoft Word to landscape?<BR><BR>&#8212; EE<\/P><IMG border=\"0\" alt=\"Spacer\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/05\/spacer.gif\" width=\"5\" height=\"5\"><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Answer\" border=\"0\" alt=\"Hey, Scripting Guy! Answer\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" width=\"34\" height=\"34\"><A href=\"http:\/\/go.microsoft.com\/fwlink\/?linkid=68779&amp;clcid=0x409\"><IMG class=\"farGraphic\" title=\"Script Center\" border=\"0\" alt=\"Script Center\" align=\"right\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/ad.jpg\" width=\"120\" height=\"288\"><\/A> \n<P>Hey, EE. We think the script that we\u2019re about to show you will answer your question; if it doesn\u2019t, however, we\u2019ll hope you cut us a little slack. After all, according to an exercise bike at the local gym, the Scripting Guy who writes this column died last night.<\/P>\n<P>Now, don\u2019t worry: the Scripting Guy actually feels pretty good. (Maybe death is overrated.) What happened is this: Last night the Scripting Guy who writes this column and his Scripting Son went to workout at the gym. After playing some basketball they sat down to ride the exercise bikes. As they started, the Scripting Guy who writes this column noticed that, even though he wasn\u2019t holding on to the heart rate monitor, the exercise bike insisted that his heart rate was 140. Oh, well, he thought; who cares?<\/P>\n<P>A few minutes into the workout, however, he noticed that every 10 seconds or so his heart rate would suddenly drop by a few beats (even though he <I>still<\/I> wasn\u2019t gripping the heart rate monitor). At first he liked that: after all, having such a low heart rate while working out was proof of the great shape he\u2019s in. As his alleged heart rate continued to drop, however, he began to worry; as his heart rate dipped into the 40s he <I>really<\/I> began to worry. And then, suddenly, his heart rate started falling, beat-by-beat, until the heart rate monitor measured 0. No heart beat? That didn\u2019t sound very good. <\/P>\n<TABLE id=\"EHD\" class=\"dataTable\" cellSpacing=\"0\" cellPadding=\"0\">\n<THEAD><\/THEAD>\n<TBODY>\n<TR class=\"record\" vAlign=\"top\">\n<TD>\n<P class=\"lastInCell\"><B>Note<\/B>. Admittedly, heart rate isn\u2019t necessarily the criteria used to determine whether someone is dead or alive; often times death is indicated by absence of any sort of brain activity. However, that methodology can\u2019t be applied to the Scripting Guy who writes this column; if it could, he would have been declared dead years ago.<\/P><\/TD><\/TR><\/TBODY><\/TABLE>\n<DIV class=\"dataTableBottomMargin\"><\/DIV>\n<P>So was the Scripting Son alarmed at the fact that, according to the exercise bike, the Scripting Dad no longer had a heart beat? Not exactly. Although they still had a good 10 minutes or so left in their workout the Scripting Dad thought the fact that he was dead should give him the right to quit early. The Scripting Son would have no part of that, however; instead, he insisted that his poor deceased father continue riding for the last 10 minutes, even forcing him \u2013 as is their custom \u2013 to sprint the final minute.<\/P>\n<P>Which, when you think about it, was really pretty impressive. After all, anyone can ride a bike while they\u2019re alive; however, we\u2019re willing to bet that even Lance Armstrong himself would have trouble riding a bike while dead.<\/P>\n<TABLE id=\"EUD\" class=\"dataTable\" cellSpacing=\"0\" cellPadding=\"0\">\n<THEAD><\/THEAD>\n<TBODY>\n<TR class=\"record\" vAlign=\"top\">\n<TD>\n<P class=\"lastInCell\"><B>Note<\/B>. Did the Scripting Guy\u2019s life flash before his eyes when he died? That\u2019s hard to say. Granted, he didn\u2019t see anything interesting as the heart rate monitor counted down to 0. But, then again, he hasn\u2019t really lived a very interesting life. So who knows?<\/P><\/TD><\/TR><\/TBODY><\/TABLE>\n<DIV class=\"dataTableBottomMargin\"><\/DIV>\n<P>Now, does all that mean that there won\u2019t be a <I>Hey, Scripting Guy!<\/I> column today? Of course not; you don\u2019t think a little thing like having no heartbeat could stop the Scripting Guys, do you? Here\u2019s a script that sets the page orientation in Microsoft Word to landscape:<\/P><PRE class=\"codeSample\">Const wdOrientLandscape = 1<\/p>\n<p>Set objWord = CreateObject(&#8220;Word.Application&#8221;)\nobjWord.Visible = True\nSet objDoc = objWord.Documents.Add()<\/p>\n<p>objDoc.PageSetup.Orientation = wdOrientLandscape\n<\/PRE>\n<P>As you can see, there\u2019s not much to this script. We start out by defining a constant named wdOrientLandscape and setting the value to 1; we probably don\u2019t need to tell you that we\u2019ll use this constant to switch the page orientation to landscape. What if we decide later on to switch the orientation back to portrait mode? No problem; in that case we just need to use a constant named wdOrientPortrait and set the value of <I>that<\/I> constant to 0:<\/P><PRE class=\"codeSample\">Const wdOrientPortrait = 0\n<\/PRE>\n<P>After defining our constant we create an instance of the <B>Word.Application<\/B> object and set the <B>Visible<\/B> property to True; that gives us an instance of Microsoft Word that we can see on screen. We call the <B>Add<\/B> method to add a new document to our instance of Word, then use this line of code to change the page orientation to landscape:<\/P><PRE class=\"codeSample\">objDoc.PageSetup.Orientation = wdOrientLandscape\n<\/PRE>\n<P>That<B><\/B><I>is<\/I> easy, isn\u2019t it? <\/P>\n<P>All we\u2019re doing in that line of code is assigning the constant wdOrientLandscape to the <B>Orientation<\/B> property of the <B>PageSetup<\/B> object (which happens to be a child object of the Document object). At that point our document will switch to landscape mode.<\/P>\n<P>Of course, if you\u2019re working in landscape mode you might want to do two additional things: you might want to ensure that the document is in Print Layout view (that way you can easily verify that the orientation really <I>has<\/I> been set to landscape) and you might want to change the Zoom (to ensure that the entire document fits on screen). Here\u2019s a bonus script that changes the View to Print Layout and the Zoom to 80 percent:<\/P><PRE class=\"codeSample\">Const wdOrientLandscape = 1\nConst wdPrintView = 3 <\/p>\n<p>Set objWord = CreateObject(&#8220;Word.Application&#8221;)\nobjWord.Visible = True\nSet objDoc = objWord.Documents.Add()<\/p>\n<p>objDoc.PageSetup.Orientation = wdOrientLandscape<\/p>\n<p>objDoc.ActiveWindow.View.Type = wdPrintView\nobjDoc.ActiveWindow.View.Zoom.Percentage = 75\n<\/PRE>\n<P>We won\u2019t bother explaining all this today; all we\u2019re really doing is modifying the <B>Type<\/B> and <B>Zoom<\/B> properties of the <B>ActiveWindow.View<\/B> object. If you\u2019d like to use a different view type (that is, something other than Print Layout), well, here\u2019s a complete list of constants and their values:<\/P>\n<TABLE id=\"EXF\" class=\"dataTable\" cellSpacing=\"0\" cellPadding=\"0\">\n<THEAD><\/THEAD>\n<TBODY>\n<TR class=\"record\" vAlign=\"top\">\n<TD>\n<P class=\"lastInCell\"><B>Constant<\/B><\/P><\/TD>\n<TD>\n<P class=\"lastInCell\"><B>Value<\/B><\/P><\/TD><\/TR>\n<TR class=\"evenRecord\" vAlign=\"top\">\n<TD>\n<P class=\"lastInCell\">wdMasterView<\/P><\/TD>\n<TD>\n<P class=\"lastInCell\">5<\/P><\/TD><\/TR>\n<TR class=\"record\" vAlign=\"top\">\n<TD>\n<P class=\"lastInCell\">wdNormalView<\/P><\/TD>\n<TD>\n<P class=\"lastInCell\">1<\/P><\/TD><\/TR>\n<TR class=\"evenRecord\" vAlign=\"top\">\n<TD>\n<P class=\"lastInCell\">wdOutlineView<\/P><\/TD>\n<TD>\n<P class=\"lastInCell\">2<\/P><\/TD><\/TR>\n<TR class=\"record\" vAlign=\"top\">\n<TD>\n<P class=\"lastInCell\">wdPrintPreview<\/P><\/TD>\n<TD>\n<P class=\"lastInCell\">4<\/P><\/TD><\/TR>\n<TR class=\"evenRecord\" vAlign=\"top\">\n<TD>\n<P class=\"lastInCell\">wdPrintView<\/P><\/TD>\n<TD>\n<P class=\"lastInCell\">3<\/P><\/TD><\/TR>\n<TR class=\"record\" vAlign=\"top\">\n<TD>\n<P class=\"lastInCell\">wdReadingView<\/P><\/TD>\n<TD>\n<P class=\"lastInCell\">7<\/P><\/TD><\/TR>\n<TR class=\"evenRecord\" vAlign=\"top\">\n<TD>\n<P class=\"lastInCell\">wdWebView<\/P><\/TD>\n<TD>\n<P class=\"lastInCell\">6<\/P><\/TD><\/TR><\/TBODY><\/TABLE>\n<DIV class=\"dataTableBottomMargin\"><\/DIV>\n<P>Just substitute the appropriate constant (and value) for wdPrintView and have at it.<\/P>\n<P>One last thing. The answer to the age-old question is this: yes, the fact that the Scripting Guy made it in to work today proves that there <I>is<\/I> life after death. The only drawback? Considering that he made it in to <I>work<\/I> suggests that our Scripting Guy didn\u2019t quite make it to heaven, if you know what we mean.<\/P>\n<P>And the fact that all the other Scripting Guys are here, too pretty much proves that, doesn\u2019t it?<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey, Scripting Guy! How can I set the document orientation in Microsoft Word to landscape?&#8212; EE Hey, EE. We think the script that we\u2019re about to show you will answer your question; if it doesn\u2019t, however, we\u2019ll hope you cut us a little slack. After all, according to an exercise bike at the local gym, [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[84,49,3,5],"class_list":["post-66563","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-microsoft-word","tag-office","tag-scripting-guy","tag-vbscript"],"acf":[],"blog_post_summary":"<p>Hey, Scripting Guy! How can I set the document orientation in Microsoft Word to landscape?&#8212; EE Hey, EE. We think the script that we\u2019re about to show you will answer your question; if it doesn\u2019t, however, we\u2019ll hope you cut us a little slack. After all, according to an exercise bike at the local gym, [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/66563","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=66563"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/66563\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=66563"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=66563"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=66563"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}