<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>JP Software Technologies</title>
	
	<link>http://www.jpsoftwaretech.com</link>
	<description>The site formerly known as Code For Excel and Outlook</description>
	<lastBuildDate>Fri, 10 Feb 2012 12:00:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/CodeForExcelAndOutlook" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="codeforexcelandoutlook" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" /><image><link>http://www.jpsoftwaretech.com/</link><url>http://img.jpsoftwaretech.com/xo.png</url><title>Logo</title></image><feedburner:emailServiceId xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">CodeForExcelAndOutlook</feedburner:emailServiceId><feedburner:feedburnerHostname xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>A small experiment in comments</title>
		<link>http://www.jpsoftwaretech.com/a-small-experiment-in-comments/</link>
		<comments>http://www.jpsoftwaretech.com/a-small-experiment-in-comments/#comments</comments>
		<pubDate>Fri, 10 Feb 2012 12:00:58 +0000</pubDate>
		<dc:creator>JP</dc:creator>
				<category><![CDATA[Off Topic]]></category>
		<category><![CDATA[comments]]></category>

		<guid isPermaLink="false">http://www.jpsoftwaretech.com/?p=2290</guid>
		<description><![CDATA[<p>Apologies in advance for this off-topic post. I assume nobody noticed, but comments on articles over 90 days old will now automatically close. It's not that I don't appreciate the comments I receive. I really hope I don't seem ungrateful. It's just that lately I'm getting too many "this is great, but can you also<br /><em>Continue Reading:</em> <a class="more-link" href="http://www.jpsoftwaretech.com/a-small-experiment-in-comments/">A small experiment in comments &#187;</a></p><p><a href="http://www.jpsoftwaretech.com/a-small-experiment-in-comments/">A small experiment in comments</a> is Copyright © <a href="http://www.jpsoftwaretech.com">JP Software Technologies</a>. All Rights Reserved.</p>]]></description>
			<content:encoded><![CDATA[<p>Apologies in advance for this off-topic post. I assume nobody noticed, but comments on articles over 90 days old will now automatically close.<br />
<span id="more-2290"></span><br />
It's not that I don't appreciate the comments I receive. I really hope I don't seem ungrateful. It's just that lately I'm getting too many "this is great, but can you also do this and that for me?" type of comments. I also see a lot of comments that are only marginally related to the article. In short, the comments section is becoming a de facto help forum, and it's just not meant to be used like that. I wish I had time to respond to each comment. Many of these comments deserve a blog post of their own. Simply ignoring them is not an option. Unfortunately, I know of no other way to encourage high-quality, targeted comments. If you do, I would <a href="http://www.jpsoftwaretech.com/contact/">love to know</a>.</p>
<p>I tried starting a forum, but you know the story about a tree falling in the forest when nobody is around.</p>
<p>So I am again trying something new. As soon as an article reaches 90 days old, WordPress will close the comment form. I may also decide to change that to 30 or 60 days. If you read an article and see "Comments are closed" at the bottom, and you want to follow up <em>specifically about that article</em>, please do one of the following:</p>
<ol>
<li>Check the existing comments. Someone may have already brought up and addressed the issue.</li>
<li>Read the <a href="http://www.jpsoftwaretech.com/faq/">FAQ</a>. Your question may be already answered there.</li>
<li>Write a response on your own blog or website. Send a trackback and it will appear at the bottom of the article in the Trackbacks section. If you don't have one, write the article and I'll <a href="http://www.jpsoftwaretech.com/contribute/">publish it for you</a> right here!</li>
<li>Post your question on one of the many active forums such as MrExcel, VBA Express, MSDN, Chandoo, ExcelGuru, Stack Overflow, and so on. Send me an email and if I have an account on the forum, I'll try to stop by and assist.</li>
<li>Send me a message on <a href="http://twitter.com/jp_2112">Twitter</a>.</li>
<li>Send me an <a href="http://www.jpsoftwaretech.com/contact/">email</a>. If you choose to go this route, please read the <a href="http://www.jpsoftwaretech.com/faq/#help">help section</a> of the FAQ first.</li>
</ol>
<p>I strongly encourage the first four options as your best chance of getting targeted help.</p>
<p>And I cannot emphasize this enough: if you choose to email me, please <strong><em>be specific</em></strong>. I get too many emails that are full blown work descriptions without any actual questions in them. </p>
<p>Sorry, TLDR!</p>
<p>If someone lets me know about an issue with an article (wrong code, bad advice, additional details etc) I will of course amend the article. But not through comments.</p>
<p>Please understand, I am not trying to discourage the interaction that is important for many blogs. There are still plenty of ways I can be reached. I really hope this doesn't come across as whining or condescending. I am not trying to hide from my critics. But as the amount of traffic grows, so is the amount of off-topic conversation. Comments are not being turned off completely, just on older posts. As usual, this is an experiment and if it looks like it's not working, I will revert to the previous state.</p>
<p>Thanks for your time. We now return you to your regularly scheduled helpings of VBA.</p>
<h2  class="related_post_title">Related Articles:</h2><ul class="related_post"><li>January 18, 2010 -- <a href="http://www.jpsoftwaretech.com/exporting-comments-using-vba/" title="Exporting Comments using VBA">Exporting Comments using VBA</a></li></ul><p><a href="http://www.jpsoftwaretech.com/a-small-experiment-in-comments/">A small experiment in comments</a> is Copyright © <a href="http://www.jpsoftwaretech.com">JP Software Technologies</a>. All Rights Reserved.</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?a=0sHcW-BfDt8:x_B-imV7agM:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?i=0sHcW-BfDt8:x_B-imV7agM:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?a=0sHcW-BfDt8:x_B-imV7agM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?a=0sHcW-BfDt8:x_B-imV7agM:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?i=0sHcW-BfDt8:x_B-imV7agM:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?a=0sHcW-BfDt8:x_B-imV7agM:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?i=0sHcW-BfDt8:x_B-imV7agM:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?a=0sHcW-BfDt8:x_B-imV7agM:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?a=0sHcW-BfDt8:x_B-imV7agM:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?i=0sHcW-BfDt8:x_B-imV7agM:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/CodeForExcelAndOutlook/~4/0sHcW-BfDt8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss />
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Reference latest version of DBEngine</title>
		<link>http://www.jpsoftwaretech.com/reference-latest-version-of-dbengine/</link>
		<comments>http://www.jpsoftwaretech.com/reference-latest-version-of-dbengine/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 12:00:15 +0000</pubDate>
		<dc:creator>JP</dc:creator>
				<category><![CDATA[Access]]></category>
		<category><![CDATA[CreateObject]]></category>
		<category><![CDATA[DAO]]></category>
		<category><![CDATA[DBEngine]]></category>

		<guid isPermaLink="false">http://www.jpsoftwaretech.com/?p=2284</guid>
		<description><![CDATA[<p>In How to get most recent DBEngine object, Access MVP Alex Dybenko shows us some VB.NET code for grabbing the latest version of DAO's DBEngine Object. It smartly uses a loop to start from the newest version and walks its way down to the lowest version, trying to set an object reference each time. But<br /><em>Continue Reading:</em> <a class="more-link" href="http://www.jpsoftwaretech.com/reference-latest-version-of-dbengine/">Reference latest version of DBEngine &#187;</a></p><p><a href="http://www.jpsoftwaretech.com/reference-latest-version-of-dbengine/">Reference latest version of DBEngine</a> is Copyright © <a href="http://www.jpsoftwaretech.com">JP Software Technologies</a>. All Rights Reserved.</p>]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://accessblog.net/2012/01/how-to-get-most-recent-dbengine-object.html">How to get most recent DBEngine object</a>, Access MVP Alex Dybenko shows us some VB.NET code for grabbing the latest version of DAO's DBEngine Object.</p>
<p>It smartly uses a loop to start from the newest version and walks its way down to the lowest version, trying to set an object reference each time. But the <a href="http://accessblog.net/2007/06/how-to-get-reference-to-dbengine.html">VBA version of the same code</a> just hardcodes each version. Why not loop in VBA as well?<br />
<span id="more-2284"></span><br />
Unfortunately a version-loop is required, because we cannot simply use <strong>CreateObject("DAO.DBEngine")</strong> like we can with other objects (Outlook.Application, Excel.Application and so on) to get whatever version exists on the local computer.</p>
<h3>Who cares about the DBEngine Object anyway?</h3>
<p>Before we start showing code, let's talk about what we can use this object for. It has a few important methods which we can leverage when working with Microsoft Access databases.</p>
<ul>
<li>CompactDatabase Method</li>
<p>The DAO.DBEngine.CompactDatabase Method may be used to compact and make copies of existing (closed) databases.</p>
<li>CreateDatabase Method</li>
<p>This method lets you create and save new databases, and returns a Database object for you to work with.</p>
<li>OpenDatabase Method</li>
<p>This method opens databases and returns a Database object.</p>
<li>SetOption Method</li>
<p>The SetOption Method lets you store temporary values for various database options, such as whether you want to display the status bar or compact on close. This is great for application-specific settings that you don't want to change permanently, but only for a particular database. See <a href="http://msdn.microsoft.com/en-us/library/aa172326(v=office.11).aspx">SetOption</a> for VBA syntax.</p>
<li>BeginTrans, CommitTrans, Rollback Methods</li>
<p>These methods, when used with a given DBEngine.Workspace object, can be used to group changes to a database.</p>
<blockquote><p>Use the BeginTrans method before updating the first record, and then, if any subsequent update fails, you can use the Rollback method to undo all of the updates. Use the CommitTrans method after you successfully update the last record.</p></blockquote>
</ul>
<h3>Get Reference to DBEngine</h3>
<p>This code is the approximate VBA equivalent of the VB.NET code from the above link.</p>
<pre class="brush: vb; title: Code:; notranslate">Public Function GetDBEngine() As Object
  Dim versions() As String
  Dim i As Long

  ' put versions from newest to oldest into array
  versions = StringToArray(&quot;120,36,35&quot;)

  ' loop through array and try to set obj reference
  For i = LBound(versions) To UBound(versions)
    On Error Resume Next
    Set GetDBEngine = CreateObject(&quot;DAO.DBEngine.&quot; &amp; versions(i))

    If Not GetDBEngine Is Nothing Then ' found it!
      Exit For
    End If
  Next i

End Function
Function StringToArray(entries As String, _
      Optional delimiter As String = &quot;,&quot;) As Variant
  StringToArray = Split(entries, delimiter)
End Function</pre>
<p>In your calling procedure, after calling GetDBEngine you need to compare it with Nothing to make sure it exists.</p>
<h4>Sample Usage:</h4>
<pre class="brush: vb; title: Code:; notranslate">Sub GetDAO()

  Dim dbeng As Object
  Set dbeng = GetDBEngine

  If dbeng Is Nothing Then
    MsgBox &quot;DAO is not available on this computer.&quot;
  End If

  ' or

  If Not dbeng Is Nothing Then
    ' your code here
  Else
    MsgBox &quot;DAO is not available on this computer.&quot;
  End If

End Sub</pre>
<h2  class="related_post_title">Related Articles:</h2><ul class="related_post"><li>April 25, 2011 -- <a href="http://www.jpsoftwaretech.com/check-if-office-is-installed/" title="Check if Office is installed">Check if Office is installed</a></li><li>July 30, 2010 -- <a href="http://www.jpsoftwaretech.com/an-introduction-to-yql-for-vba/" title="An Introduction to YQL for VBA">An Introduction to YQL for VBA</a></li><li>June 8, 2010 -- <a href="http://www.jpsoftwaretech.com/an-exploration-of-ie-browser-methods-part-ii/" title="An exploration of IE browser methods, part II">An exploration of IE browser methods, part II</a></li></ul><p><a href="http://www.jpsoftwaretech.com/reference-latest-version-of-dbengine/">Reference latest version of DBEngine</a> is Copyright © <a href="http://www.jpsoftwaretech.com">JP Software Technologies</a>. All Rights Reserved.</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?a=TQadXjmobyU:w4K8iKSZ2Mc:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?i=TQadXjmobyU:w4K8iKSZ2Mc:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?a=TQadXjmobyU:w4K8iKSZ2Mc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?a=TQadXjmobyU:w4K8iKSZ2Mc:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?i=TQadXjmobyU:w4K8iKSZ2Mc:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?a=TQadXjmobyU:w4K8iKSZ2Mc:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?i=TQadXjmobyU:w4K8iKSZ2Mc:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?a=TQadXjmobyU:w4K8iKSZ2Mc:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?a=TQadXjmobyU:w4K8iKSZ2Mc:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?i=TQadXjmobyU:w4K8iKSZ2Mc:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/CodeForExcelAndOutlook/~4/TQadXjmobyU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss />
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remove Flags from Inbox Emails</title>
		<link>http://www.jpsoftwaretech.com/remove-flags-from-inbox-emails/</link>
		<comments>http://www.jpsoftwaretech.com/remove-flags-from-inbox-emails/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 12:00:04 +0000</pubDate>
		<dc:creator>JP</dc:creator>
				<category><![CDATA[Outlook]]></category>
		<category><![CDATA[flags]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://www.jpsoftwaretech.com/?p=2283</guid>
		<description><![CDATA[<p>In Don’t let senders flag message with Reminder for me there is a method for removing follow up flags from emails. Here I will present a VBA method (both manual and event-driven) for doing the same. Personally, I dislike those follow up flags. The mere fact that an email was sent implies that some kind<br /><em>Continue Reading:</em> <a class="more-link" href="http://www.jpsoftwaretech.com/remove-flags-from-inbox-emails/">Remove Flags from Inbox Emails &#187;</a></p><p><a href="http://www.jpsoftwaretech.com/remove-flags-from-inbox-emails/">Remove Flags from Inbox Emails</a> is Copyright © <a href="http://www.jpsoftwaretech.com">JP Software Technologies</a>. All Rights Reserved.</p>]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://www.msoutlook.info/question/637">Don’t let senders flag message with Reminder for me</a> there is a method for removing follow up flags from emails. Here I will present a VBA method (both manual and event-driven) for doing the same.<br />
<span id="more-2283"></span><br />
Personally, I dislike those follow up flags. The mere fact that an email was sent implies that some kind of response or follow up is being requested. A flag is just piling on. I will decide if and when to follow up on an email.</p>
<h3>Manual / On Demand Method</h3>
<p>This code may be run as needed to remove flags on existing emails in the default Inbox.</p>
<pre class="brush: vb; title: Code:; notranslate">Sub RemoveFlags()
  Dim itms As Outlook.Items
  Dim msg As Outlook.mailItem
  Dim i As Long

  ' get default Inbox folder items
  Set itms = GetItems(GetNS(GetOutlookApp), olFolderInbox)

  For i = 1 To itms.count
    If TypeName(itms.Item(i)) = &quot;MailItem&quot; Then

      Set msg = itms.Item(i)
      ' remove flags
      With msg
        .FlagStatus = olNoFlag
        .FlagIcon = olNoFlagIcon
        .Save
      End With

    End If
  Next i
End Sub</pre>
<p>This code should be placed in a standard module in Outlook's VBA editor (see <a href="http://www.jpsoftwaretech.com/outlook-vba/where-do-i-put-my-outlook-vba-code/">Where do I put my Outlook VBA code</a> for placement assistance).</p>
<h3>Event Handler</h3>
<p>Suppose you wanted to remove flags on all incoming emails automatically. Kudos to you for being brave. I started with the event handler found at <a href="http://www.jpsoftwaretech.com/outlook-vba/stock-event-code/">Stock Event Code</a> and produced this code:</p>
<pre class="brush: vb; title: Code:; notranslate">Private WithEvents Items As Outlook.Items

Private Sub Application_Startup()
  Set Items = GetItems(GetNS(GetOutlookApp), olFolderInbox)
End Sub

Private Sub Items_ItemAdd(ByVal item As Object)
  On Error GoTo ErrorHandler

  Dim msg As Outlook.mailItem

  If TypeName(item) = &quot;MailItem&quot; Then
    Set msg = item
    With msg
      .FlagStatus = olNoFlag
      .FlagIcon = olNoFlagIcon
      .Save
    End With
  End If
ProgramExit:
  Exit Sub
ErrorHandler:
  MsgBox Err.Number &amp; &quot; - &quot; &amp; Err.Description
  Resume ProgramExit
End Sub</pre>
<p>This code should be placed in the <strong>ThisOutlookSession</strong> module in Outlook's VBA editor (see <a href="http://www.jpsoftwaretech.com/outlook-vba/where-do-i-put-my-outlook-vba-code/">Where do I put my Outlook VBA code</a> for placement assistance). Restart Outlook and then ask someone to send you an email with a follow up flag.</p>
<h3>Ancillary Functions</h3>
<p>Note that both of the above sections of code need these procedures. Paste them into a standard module.</p>
<pre class="brush: vb; title: Code:; notranslate">Function GetItems(olNS As Outlook.NameSpace, _
                     folder As OlDefaultFolders) As Outlook.Items
  Set GetItems = olNS.GetDefaultFolder(folder).Items
End Function
Function GetNS(ByRef app As Outlook.Application) As Outlook.NameSpace
  Set GetNS = app.GetNamespace(&quot;MAPI&quot;)
End Function
Function GetOutlookApp() As Outlook.Application
  Set GetOutlookApp = Outlook.Application
End Function</pre>
<h2  class="related_post_title">Related Articles:</h2><ul class="related_post"><li>January 9, 2012 -- <a href="http://www.jpsoftwaretech.com/annoying-website-name-generator/" title="Annoying Website Name Generator in VBA and PHP">Annoying Website Name Generator in VBA and PHP</a></li><li>December 26, 2011 -- <a href="http://www.jpsoftwaretech.com/validating-userform-data/" title="Validating Userform Data">Validating Userform Data</a></li><li>July 29, 2011 -- <a href="http://www.jpsoftwaretech.com/new-outlook-blog/" title="New Outlook Blog">New Outlook Blog</a></li></ul><p><a href="http://www.jpsoftwaretech.com/remove-flags-from-inbox-emails/">Remove Flags from Inbox Emails</a> is Copyright © <a href="http://www.jpsoftwaretech.com">JP Software Technologies</a>. All Rights Reserved.</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?a=MVh4qshntvI:XewwCkcwCWQ:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?i=MVh4qshntvI:XewwCkcwCWQ:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?a=MVh4qshntvI:XewwCkcwCWQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?a=MVh4qshntvI:XewwCkcwCWQ:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?i=MVh4qshntvI:XewwCkcwCWQ:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?a=MVh4qshntvI:XewwCkcwCWQ:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?i=MVh4qshntvI:XewwCkcwCWQ:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?a=MVh4qshntvI:XewwCkcwCWQ:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?a=MVh4qshntvI:XewwCkcwCWQ:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?i=MVh4qshntvI:XewwCkcwCWQ:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/CodeForExcelAndOutlook/~4/MVh4qshntvI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss />
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Determine local system32 folder</title>
		<link>http://www.jpsoftwaretech.com/determine-local-system32-folder/</link>
		<comments>http://www.jpsoftwaretech.com/determine-local-system32-folder/#comments</comments>
		<pubDate>Thu, 26 Jan 2012 12:00:34 +0000</pubDate>
		<dc:creator>JP</dc:creator>
				<category><![CDATA[VBA]]></category>
		<category><![CDATA[Environ]]></category>
		<category><![CDATA[system32]]></category>

		<guid isPermaLink="false">http://www.jpsoftwaretech.com/?p=2279</guid>
		<description><![CDATA[<p>Something from the FAQ which probably doesn't belong there: Why is this important? I really don't know. But it was a few minutes of fun to find out how to do it. The system32 folder does contain a lot of DLLs which you can leverage in VBA. Related Articles:July 8, 2009 -- VBA Tips, Tricks<br /><em>Continue Reading:</em> <a class="more-link" href="http://www.jpsoftwaretech.com/determine-local-system32-folder/">Determine local system32 folder &#187;</a></p><p><a href="http://www.jpsoftwaretech.com/determine-local-system32-folder/">Determine local system32 folder</a> is Copyright © <a href="http://www.jpsoftwaretech.com">JP Software Technologies</a>. All Rights Reserved.</p>]]></description>
			<content:encoded><![CDATA[<p>Something from the <a href="http://www.jpsoftwaretech.com/faq/">FAQ</a> which probably doesn't belong there:<br />
<span id="more-2279"></span></p>
<pre class="brush: vb; title: Code:; notranslate">Function GetSystem32Folder() As String
 GetSystem32Folder = Environ(&quot;SystemRoot&quot;) &amp; &quot;\system32\&quot;
End Function</pre>
<p>Why is this important? I really don't know. But it was a few minutes of fun to find out how to do it. The system32 folder does contain a lot of DLLs which you can leverage in VBA.</p>
<h2  class="related_post_title">Related Articles:</h2><ul class="related_post"><li>July 8, 2009 -- <a href="http://www.jpsoftwaretech.com/vba-tips-tricks-and-best-practices/" title="VBA Tips, Tricks and Best Practices, Part One of Four">VBA Tips, Tricks and Best Practices, Part One of Four</a></li></ul><p><a href="http://www.jpsoftwaretech.com/determine-local-system32-folder/">Determine local system32 folder</a> is Copyright © <a href="http://www.jpsoftwaretech.com">JP Software Technologies</a>. All Rights Reserved.</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?a=yaGt7q6Kp1I:rHES3bLOrbI:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?i=yaGt7q6Kp1I:rHES3bLOrbI:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?a=yaGt7q6Kp1I:rHES3bLOrbI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?a=yaGt7q6Kp1I:rHES3bLOrbI:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?i=yaGt7q6Kp1I:rHES3bLOrbI:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?a=yaGt7q6Kp1I:rHES3bLOrbI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?i=yaGt7q6Kp1I:rHES3bLOrbI:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?a=yaGt7q6Kp1I:rHES3bLOrbI:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?a=yaGt7q6Kp1I:rHES3bLOrbI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?i=yaGt7q6Kp1I:rHES3bLOrbI:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/CodeForExcelAndOutlook/~4/yaGt7q6Kp1I" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss />
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Len vs Empty, which is faster</title>
		<link>http://www.jpsoftwaretech.com/len-vs-empty-which-is-faster/</link>
		<comments>http://www.jpsoftwaretech.com/len-vs-empty-which-is-faster/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 12:00:24 +0000</pubDate>
		<dc:creator>JP</dc:creator>
				<category><![CDATA[VBA]]></category>
		<category><![CDATA[comparison test]]></category>
		<category><![CDATA[Empty]]></category>
		<category><![CDATA[Len]]></category>

		<guid isPermaLink="false">http://www.jpsoftwaretech.com/?p=2247</guid>
		<description><![CDATA[<p>In Is That String Really Empty? I mentioned that Empty returns the same response as Len when checking variable- and fixed-length strings. Let's test which one is faster. I am going to assume that Len is faster. To make things simpler I limited my tests to variable-length strings only. The Test Procedure As in previous<br /><em>Continue Reading:</em> <a class="more-link" href="http://www.jpsoftwaretech.com/len-vs-empty-which-is-faster/">Len vs Empty, which is faster &#187;</a></p><p><a href="http://www.jpsoftwaretech.com/len-vs-empty-which-is-faster/">Len vs Empty, which is faster</a> is Copyright © <a href="http://www.jpsoftwaretech.com">JP Software Technologies</a>. All Rights Reserved.</p>]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://www.jpsoftwaretech.com/is-that-string-really-empty/">Is That String Really Empty?</a> I mentioned that Empty returns the same response as Len when checking variable- and fixed-length strings. Let's test which one is faster.</p>
<p><span id="more-2247"></span></p>
<p>I am going to assume that Len is faster. To make things simpler I limited my tests to variable-length strings only.</p>
<h3>The Test Procedure</h3>
<p>As in previous posts, I wrote a simple non-scientific loop to casually test the speed of both functions. </p>
<pre class="brush: vb; title: Code:; notranslate">Sub TestLenEmpty()

  Dim i As Long
  Dim str1 As String
  Dim starttimeLen As Single
  Dim endtimeLen As Single
  Dim starttimeEmpty As Single
  Dim endtimeEmpty As Single
  Dim msg As String
  Dim hasValue As Boolean

  Const numberOfLoops As Long = 100000000

  str1 = &quot;Hello World&quot;

  ' use Len
  starttimeLen = Timer
  For i = 1 To numberOfLoops
    hasValue = (Len(str1) &gt; 0)
  Next i
  endtimeLen = Timer

  ' use Empty
  starttimeEmpty = Timer
  For i = 1 To numberOfLoops
    hasValue = (str1 = Empty)
  Next i
  endtimeEmpty = Timer

  msg = &quot;Number of iterations: &quot; &amp; numberOfLoops &amp; vbCrLf
  msg = msg &amp; &quot;Using Len: &quot; &amp; _
    Format(endtimeLen - starttimeLen, &quot;#.###&quot;) &amp; &quot; seconds&quot; &amp; vbCrLf
  msg = msg &amp; &quot;Using Empty: &quot; &amp; _
    Format(endtimeEmpty - starttimeEmpty, &quot;#.###&quot;) &amp; &quot; seconds&quot; &amp; vbCrLf

  MsgBox msg
End Sub</pre>
<p>According to Excel's Visual Basic Help, <strong>Empty</strong> is a Variant subtype, so I expect some implicit type conversion here when comparing string values to <strong>Empty</strong>. What I didn't expect was the dramatic difference in speed.</p>
<h3>Results</h3>
<p>At 100,000 loop iterations, the difference is minimal:</p>
<p><img src="http://img.jpsoftwaretech.com/LenEmpty_100000.PNG" alt="Len vs Empty" title="Len vs Empty with 100,000 iterations" width="170" height="133" /></p>
<p>At 1,000,000 iterations, both loops are still very quick, but starting to separate:</p>
<p><img src="http://img.jpsoftwaretech.com/LenEmpty_1000000.PNG" alt="Len vs Empty" title="Len vs Empty with 1,000,000 iterations" width="176" height="133" /></p>
<p>At 10,000,000 iterations it takes a full second longer for the second loop:</p>
<p><img src="http://img.jpsoftwaretech.com/LenEmpty_10000000.PNG" alt="Len vs Empty" title="Len vs Empty with 10,000,000 iterations" width="182" height="133" /></p>
<p>Finally, at 100 million iterations, the difference is striking: a full eleven seconds longer!</p>
<p><img src="http://img.jpsoftwaretech.com/LenEmpty_100000000.PNG" alt="Len vs Empty" title="Len vs Empty with 100,000,000 iterations" width="188" height="133" /></p>
<h3>Conclusion</h3>
<p>There is simply no substitute for Len (no pun intended). It is the fastest method for checking string length (and therefore, whether strings are empty), and it scales well. I never really used Empty anyway, and I don't plan on starting now.</p>
<h2  class="related_post_title">Related Articles:</h2><ul class="related_post"><li>January 6, 2012 -- <a href="http://www.jpsoftwaretech.com/is-that-string-really-empty/" title="Is That String Really Empty?">Is That String Really Empty?</a></li><li>January 4, 2012 -- <a href="http://www.jpsoftwaretech.com/len-or-lenb-which-is-faster/" title="Len or LenB, which is faster?">Len or LenB, which is faster?</a></li><li>December 29, 2011 -- <a href="http://www.jpsoftwaretech.com/len-vs-blank-strings-vs-vbnullstring/" title="Len vs blank strings vs vbNullString">Len vs blank strings vs vbNullString</a></li></ul><p><a href="http://www.jpsoftwaretech.com/len-vs-empty-which-is-faster/">Len vs Empty, which is faster</a> is Copyright © <a href="http://www.jpsoftwaretech.com">JP Software Technologies</a>. All Rights Reserved.</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?a=tTB3NBFuLGw:qYh1GJY9K8I:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?i=tTB3NBFuLGw:qYh1GJY9K8I:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?a=tTB3NBFuLGw:qYh1GJY9K8I:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?a=tTB3NBFuLGw:qYh1GJY9K8I:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?i=tTB3NBFuLGw:qYh1GJY9K8I:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?a=tTB3NBFuLGw:qYh1GJY9K8I:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?i=tTB3NBFuLGw:qYh1GJY9K8I:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?a=tTB3NBFuLGw:qYh1GJY9K8I:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?a=tTB3NBFuLGw:qYh1GJY9K8I:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/CodeForExcelAndOutlook?i=tTB3NBFuLGw:qYh1GJY9K8I:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/CodeForExcelAndOutlook/~4/tTB3NBFuLGw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss />
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

