<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>OfficeDeveloper.NET&#187; Scripts</title>
	<atom:link href="http://officedeveloper.net/tag/scripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://officedeveloper.net</link>
	<description></description>
	<lastBuildDate>Sat, 12 May 2012 09:40:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Use VBA To Reset Task Due Dates in Outlook</title>
		<link>http://officedeveloper.net/2009/02/05/use-vba-to-reset-task-due-dates-in-outlook/</link>
		<comments>http://officedeveloper.net/2009/02/05/use-vba-to-reset-task-due-dates-in-outlook/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 05:17:58 +0000</pubDate>
		<dc:creator>Ty Anderson</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Office Development]]></category>
		<category><![CDATA[Outlook]]></category>
		<category><![CDATA[Samples]]></category>
		<category><![CDATA[Add Ins]]></category>
		<category><![CDATA[Due Date]]></category>
		<category><![CDATA[Due Dates]]></category>
		<category><![CDATA[Getdefaultfolder]]></category>
		<category><![CDATA[Mapi]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Monday Morning]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[Vba Code]]></category>

		<guid isPermaLink="false">http://officedeveloper.net/use-vba-to-reset-task-due-dates-in-outlook/</guid>
		<description><![CDATA[There was an earlier version of this post. It had more words and as it went on and on about how I track damn near everything in Outlook. It’s true. Everything. If I don’t track something I want to do or have to do as an Outlook task, it won’t get done. I deleted that [...]]]></description>
			<content:encoded><![CDATA[<p>There was an earlier version of this post. It had more words and as it went on and on about how I track damn near everything in Outlook. It’s true. Everything. If I don’t track something I want to do or have to do as an Outlook task, it won’t get done. </p>
<p>I deleted that post by accident as I thought I was deleting something else. As it turns out, the wrong Window had the focus when I hit the Delete button and I deleted this post. Dammit!</p>
<p>Anyways, I always fall way behind on the deadlines I set for my tasks. So each Monday morning, I set the deadlines to a week from the current day.</p>
<p>Here is the VBA code to achieve this.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 107.27%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; height: 528px; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">Sub</span> ResetTaskDeadlines()
    <span style="color: #0000ff">Dim</span> ns <span style="color: #0000ff">As</span> <span style="color: #0000ff">NameSpace</span>
    <span style="color: #0000ff">Dim</span> fld <span style="color: #0000ff">As</span> Folder
    <span style="color: #0000ff">Dim</span> task <span style="color: #0000ff">As</span> TaskItem
    <span style="color: #0000ff">Dim</span> items <span style="color: #0000ff">As</span> Outlook.items
    <span style="color: #0000ff">Dim</span> rest <span style="color: #0000ff">As</span> Outlook.items
    <span style="color: #0000ff">Dim</span> filterSQL <span style="color: #0000ff">As</span> <span style="color: #0000ff">String</span>

    <span style="color: #0000ff">Set</span> ns = Application.GetNamespace(<span style="color: #006080">&quot;MAPI&quot;</span>)
    <span style="color: #0000ff">Set</span> fld = ns.GetDefaultFolder(olFolderTasks)
    <span style="color: #0000ff">Set</span> items = fld.items
    filterSQL = <span style="color: #006080">&quot;@SQL=&quot;</span> &amp; <span style="color: #006080">&quot;&quot;</span><span style="color: #006080">&quot;http://schemas.microsoft.com/mapi/id/&quot;</span>
    filterSQL = filterSQL &amp; <span style="color: #006080">&quot;{00062003-0000-0000-C000-000000000046}/&quot;</span>
    filterSQL = filterSQL &amp; <span style="color: #006080">&quot;81010003&quot;</span><span style="color: #006080">&quot;&quot;</span> &amp; <span style="color: #006080">&quot; &lt;&gt; 2&quot;</span>
    <span style="color: #0000ff">Set</span> rest = items.Restrict(<span style="color: #006080">&quot;[Status] &lt;&gt; 'Completed'&quot;</span>)

    <span style="color: #0000ff">For</span> <span style="color: #0000ff">Each</span> task <span style="color: #0000ff">In</span> rest
    <span style="color: #008000">''UNCOMMENT THE OPTION YOU WANT TO USE</span>
        <span style="color: #008000">''task.DueDate = &quot;1/1/4501&quot; 'Set to NO Due Date</span>
        <span style="color: #008000">''task.DueDate = task.DueDate + 7 ' Set to 7 days from current due date</span>
        task.DueDate = today() + 7 <span style="color: #008000">'Set to a week from today</span>
        <span style="color: #008000">''task.DueDate = FirstDayOfNextMonth ' Set to first day of next month</span>
        <span style="color: #008000">'task.Save</span>
    <span style="color: #0000ff">Next</span>

<span style="color: #0000ff">End</span> <span style="color: #0000ff">Sub</span>

<span style="color: #0000ff">Function</span> FirstDayOfNextMonth() <span style="color: #0000ff">As</span> <span style="color: #0000ff">Date</span>
   <span style="color: #0000ff">Dim</span> d <span style="color: #0000ff">As</span> <span style="color: #0000ff">Date</span>
   d = <span style="color: #0000ff">Date</span>
   FirstDayOfNextMonth = DateSerial(Year(d), Month(d) + 1, 1)
<span style="color: #0000ff">End</span> Function</pre>
</div>
<p>I pretty much use VSTO to build Outlook add-ins professionally. But for quick personally useful scripts like this, VBA still reins.</p>
]]></content:encoded>
			<wfw:commentRss>http://officedeveloper.net/2009/02/05/use-vba-to-reset-task-due-dates-in-outlook/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

