{"id":65533,"date":"2007-02-13T00:47:00","date_gmt":"2007-02-13T00:47:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2007\/02\/13\/hey-scripting-guy-how-can-i-configure-office-excel-to-autosave-every-5-minutes\/"},"modified":"2007-02-13T00:47:00","modified_gmt":"2007-02-13T00:47:00","slug":"hey-scripting-guy-how-can-i-configure-office-excel-to-autosave-every-5-minutes","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/hey-scripting-guy-how-can-i-configure-office-excel-to-autosave-every-5-minutes\/","title":{"rendered":"Hey, Scripting Guy! How Can I Configure Office Excel to Autosave Every 5 Minutes?"},"content":{"rendered":"<h2><img decoding=\"async\" height=\"34\" width=\"34\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" align=\"left\" alt=\"Hey, Scripting Guy! Question\" border=\"0\" title=\"Hey, Scripting Guy! Question\" class=\"nearGraphic\" \/> <\/h2>\n<p>Hey, Scripting Guy! How can I configure Office Excel to autosave every 5 minutes?<\/p>\n<p>&#8212; KK<\/p>\n<p><img decoding=\"async\" height=\"5\" width=\"5\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/05\/spacer.gif\" alt=\"Spacer\" border=\"0\" \/><img decoding=\"async\" height=\"34\" width=\"34\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" align=\"left\" alt=\"Hey, Scripting Guy! Answer\" border=\"0\" title=\"Hey, Scripting Guy! Answer\" class=\"nearGraphic\" \/><a href=\"http:\/\/go.microsoft.com\/fwlink\/?linkid=68779&amp;clcid=0x409\"><img decoding=\"async\" height=\"288\" width=\"120\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/ad.jpg\" align=\"right\" alt=\"Script Center\" border=\"0\" title=\"Script Center\" class=\"farGraphic\" \/><\/a><\/p>\n<p>Hey, KK. You know, that&rsquo;s a good question. As it turns out, the autosave capability in Microsoft Excel &ndash; hey, wait a minute: do you realize what day it is? Today is the first day of the <a href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/funzone\/games\/default.mspx\"><b>2007 Winter Scripting Games<\/b><\/a>; why in the <i>world<\/i> are you reading the <i>Hey, Scripting Guy!<\/i> column?!? After all, even as we speak you should be writing a script that calculates the Chinese astrological year or unscrambling scrambled scripting terms. Quit wasting your time and get going on the Games! <\/p>\n<p>Um, not that <i>Hey, Scripting Guy!<\/i> is a waste of time, mind you; it&rsquo;s just that the Scripting Games are special: after all, they represent the opportunity for you to match your scripting skills with script writers from all around the world. That&rsquo;s an opportunity that only comes once a year, which means you don&rsquo;t want to miss it.<\/p>\n<p>Besides, you aren&rsquo;t going to win a <a href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/funzone\/games\/games07\/bobble.mspx\"><b>Dr. Scripto bobblehead<\/b><\/a> by reading this column, that&rsquo;s for sure.<\/p>\n<p>On the other hand, KK, you&rsquo;re probably one of those people who have already finished every event in every division. Last year, during the inaugural Scripting Games, we worried about whether we had made the events too hard and whether we gave people enough time to write their scripts. Those concerns were answered soon enough: just a few hours into day 1 of the 2006 Games we&rsquo;d already received 300 completed (and correct) entries. And no doubt many of you wrote those scripts with one hand tied behind your backs to boot.<\/p>\n<p>Show-offs!<\/p>\n<p>So what the heck: if you have time to compete in the 2007 Scripting Games <i>and<\/i> to configure Excel to autosave every 5 minutes, well, we&rsquo;ll do what we can to help you out:<\/p>\n<pre class=\"codeSample\">Set objExcel = CreateObject(\"Excel.Application\")\n\nobjExcel.AutoRecover.Enabled = True\nobjExcel.AutoRecover.Time = 5<\/pre>\n<p>As you can see, this is a simple-enough little script, even for the Scripting Guys (who really did think that the events in last year&rsquo;s Scripting Games were challenging). We start out by creating an instance of the <b>Excel.Application<\/b> object. In this script, however, we don&rsquo;t bother setting the <b>Visible<\/b> property to True. Why not? Because configuring the autosave time is going to take only a split second; it just seemed silly to show Excel onscreen and then immediately make it disappear. But if you&rsquo;d like to see Excel anyway, just so you know that <i>something<\/i> is happening, then make this the second line of code in the script:<\/p>\n<pre class=\"codeSample\">objExcel.Visible = true<\/pre>\n<p>After creating our instance of Excel we then configure two different property values. To begin with, we set the value of the <b>AutoRecover.Enabled<\/b> property to True; that simply makes sure that autosave is actually enabled. What if you want to <i>disable<\/i> autosave? You got it: just set Autorecover.Enabled to False:<\/p>\n<pre class=\"codeSample\">objExcel.AutoRecover.Enabled = False<\/pre>\n<p>Next we set the value of the <b>AutoRecover.Time<\/b> property to 5 which, needless to say, sets the autosave interval to 5 minutes. Want to autosave every <i>20<\/i> minutes? No problem; just use this code instead:<\/p>\n<pre class=\"codeSample\">objExcel.AutoRecover.Time = 20<\/pre>\n<p>And that&rsquo;s all we have to do; we don&rsquo;t even have to call the Quit method and explicitly dismiss Excel. That&rsquo;s because we didn&rsquo;t add a workbook to our instance of Excel; in a case like that, when you don&rsquo;t add a workbook, Excel automatically terminates at the same time the script terminates.<\/p>\n<p>Incidentally, if you&rsquo;d like to verify that your script worked you can use this code to retrieve the values of the Enabled, Time, and <b>AutoRecover.Path<\/b> properties:<\/p>\n<pre class=\"codeSample\">Set objExcel = CreateObject(\"Excel.Application\")\n\nWscript.Echo \"AutoRecover enabled: \" &amp; objExcel.AutoRecover.Enabled\nWscript.Echo \"AutoRecover interval: \" &amp; objExcel.AutoRecover.Time\nWscript.Echo \"AutoRecover path: \" &amp; objExcel.AutoRecover.Path <\/pre>\n<p>In turn, that returns information similar to this:<\/p>\n<pre class=\"codeSample\"><pre class=\"codeSample\">AutoRecover enabled: True\nAutoRecover interval: 10\nAutoRecover path: C:\\Documents and Settings\\kenmyer\\Application Data\\Microsoft\\Excel\\<\/pre>\n<p>We hope that helps, KK. And we hope to see all of you take part in the Scripting Games: the Games are fun, they&rsquo;re challenging, and there are some cool prizes to be won. The truth is, there&rsquo;s really no reason <i>not<\/i> to take part.<\/p>\n<p>Well, unless, of course, you&rsquo;re too much of a chicken.<\/p>\n<table cellpadding=\"0\" cellspacing=\"0\" class=\"dataTable\" id=\"EKF\">\n<thead><\/thead>\n<tbody>\n<tr valign=\"top\" class=\"record\">\n<td>\n<p><b>Note<\/b>. The Scripting Editor has just informed us that we can&rsquo;t call our readers chickens; please accept our apologies. Instead, today&rsquo;s concluding sentence should have read as follows:<\/p>\n<p>Well, unless, of course, you&rsquo;re too much of a scaredy-cat.<\/p>\n<p>Thank you. And good luck in the Games!<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>Hey, Scripting Guy! How can I configure Office Excel to autosave every 5 minutes? &#8212; KK Hey, KK. You know, that&rsquo;s a good question. As it turns out, the autosave capability in Microsoft Excel &ndash; hey, wait a minute: do you realize what day it is? Today is the first day of the 2007 Winter [&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":[711,48,49,3,5],"class_list":["post-65533","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-excel-application","tag-microsoft-excel","tag-office","tag-scripting-guy","tag-vbscript"],"acf":[],"blog_post_summary":"<p>Hey, Scripting Guy! How can I configure Office Excel to autosave every 5 minutes? &#8212; KK Hey, KK. You know, that&rsquo;s a good question. As it turns out, the autosave capability in Microsoft Excel &ndash; hey, wait a minute: do you realize what day it is? Today is the first day of the 2007 Winter [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/65533","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=65533"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/65533\/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=65533"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=65533"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=65533"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}