<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/rss2full.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Code For Excel And Outlook Blog</title>
	
	<link>http://www.codeforexcelandoutlook.com/blog</link>
	<description>VBA macro code samples for MS Excel and Outlook</description>
	<pubDate>Fri, 21 Nov 2008 04:14:21 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
	<language>en</language>
			<image><link>http://www.codeforexcelandoutlook.com/blog/</link><url>http://www.codeforexcelandoutlook.com/logos/gray.gif</url><title>Logo</title></image><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/codeforexcelandoutlook/kylx" type="application/rss+xml" /><feedburner:emailServiceId>1575298</feedburner:emailServiceId><feedburner:feedburnerHostname>http://www.feedburner.com</feedburner:feedburnerHostname><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.feedburner.com%2Fcodeforexcelandoutlook%2Fkylx" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Fcodeforexcelandoutlook%2Fkylx" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://feeds.my.aol.com/add.jsp?url=http%3A%2F%2Ffeeds.feedburner.com%2Fcodeforexcelandoutlook%2Fkylx" src="http://o.aolcdn.com/favorites.my.aol.com/webmaster/ffclient/webroot/locale/en-US/images/myAOLButtonSmall.gif">Subscribe with My AOL</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://feeds.feedburner.com/codeforexcelandoutlook/kylx" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Fcodeforexcelandoutlook%2Fkylx" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Fcodeforexcelandoutlook%2Fkylx" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare href="http://www.live.com/?add=http%3A%2F%2Ffeeds.feedburner.com%2Fcodeforexcelandoutlook%2Fkylx" src="http://tkfiles.storage.msn.com/x1piYkpqHC_35nIp1gLE68-wvzLZO8iXl_JMledmJQXP-XTBOLfmQv4zhj4MhcWEJh_GtoBIiAl1Mjh-ndp9k47If7hTaFno0mxW9_i3p_5qQw">Subscribe with Live.com</feedburner:feedFlare><feedburner:feedFlare href="http://www.addtoany.com/?linkname=Code%20For%20Excel%20And%20Outlook%20Blog&amp;linkurl=http%3A%2F%2Ffeeds.feedburner.com%2Fcodeforexcelandoutlook%2Fkylx&amp;type=feed" src="http://www.addtoany.com/addfr-b.gif">Add to Any Feed Reader</feedburner:feedFlare><feedburner:browserFriendly>Thanks for viewing my feed. If you would like to subscribe, the options on this page are available for you to add this feed to whatever reader you choose.</feedburner:browserFriendly><item>
		<title>Take advantage of Intellisense when writing late bound code</title>
		<link>http://www.codeforexcelandoutlook.com/blog/2008/11/take-advantage-of-intellisense-when-writing-late-bound-code/</link>
		<comments>http://www.codeforexcelandoutlook.com/blog/2008/11/take-advantage-of-intellisense-when-writing-late-bound-code/#comments</comments>
		<pubDate>Mon, 17 Nov 2008 14:51:37 +0000</pubDate>
		<dc:creator>JP</dc:creator>
		
		<category><![CDATA[Excel]]></category>

		<category><![CDATA[VBA]]></category>

		<category><![CDATA[early binding]]></category>

		<category><![CDATA[Intellisense]]></category>

		<category><![CDATA[late binding]]></category>

		<category><![CDATA[Scripting.FileSystemObject]]></category>

		<guid isPermaLink="false">http://www.codeforexcelandoutlook.com/blog/?p=328</guid>
		<description>&amp;#160;&amp;#160;&amp;#160;&amp;#160;Many people are familiar with the page on binding found on Dick Kusleika's website "Dick's Clicks" which advises the following:

To get the most out of the VBA development environment and still write robust code, you should write the code early bound, but change it to late bound before distributing it.  Even if you write [...]</description>
			<content:encoded><![CDATA[<p>&nbsp;&nbsp;&nbsp;&nbsp;Many people are familiar with the page on binding found on Dick Kusleika's website "<a href="http://www.dicks-clicks.com/excel/olBinding.htm" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.dicks-clicks.com');">Dick's Clicks</a>" which advises the following:</p>
<blockquote><p>
<strong>To get the most out of the VBA development environment and still write robust code, you should write the code early bound, but change it to late bound before distributing it.  Even if you write it for personal use only, it makes sense to convert it to late bound.  Someday you will have a different computer or send it to your brother and it won't work because they will have an earlier version.  If you're a die-hard procrastinator like me, you will be cursing yourself for not converting to late bound sooner.</strong>
</p></blockquote>
<p>&nbsp;&nbsp;&nbsp;&nbsp;The page also provides a convenient checklist for getting this done:</p>
<blockquote><p>
<strong>Late Bound Conversion Checklist</p>
<ul>
<li>Change all declarations from Outlook objects to the generic Object data type</li>
<li>Change Set statements to GetObject or CreateObject</li>
<li>Change any built-in constants to their intrinsic values</li>
<li>Add optional arguments that have a default value</li>
</ul>
<p></strong>
</p></blockquote>
<p>&nbsp;&nbsp;&nbsp;&nbsp;In this post I am going to go through these steps and show you exactly how to convert early bound to late bound code, taking advantage of Intellisense along the way, to get the best of both worlds, if you will.</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;First, here's a small sub that lists all of the files in a folder in column A. Before I wrote the code, I set a reference to the <a href="http://msdn.microsoft.com/en-us/library/aa164509(office.10).aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/msdn.microsoft.com');">Microsoft Scripting Runtime</a>. That way, we can take advantage of Intellisense to write our code.</p>
<p></p>
<div class="igBar"><span id="lvb-7"><a href="#" onclick="javascript:showPlainTxt('vb-7'); return false;">plain text version</a></span></div>
<div class="syntax_hilite"><span class="langName">VBA:</span>
<div id="vb-7">
<div class="vb">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Sub</span> ListFiles_1<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Dim</span> fso <span style="color: #b1b100;">As</span> Scripting.<span style="color: #66cc66;">FileSystemObject</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Dim</span> filen <span style="color: #b1b100;">As</span> Scripting.<span style="color: #66cc66;">File</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Dim</span> NextRow <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Long</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">On</span> <span style="color: #b1b100;">Error</span> <span style="color: #b1b100;">Resume</span> <span style="color: #b1b100;">Next</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Set</span> fso = <span style="color: #b1b100;">New</span> Scripting.<span style="color: #66cc66;">FileSystemObject</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">On</span> <span style="color: #b1b100;">Error</span> <span style="color: #b1b100;">GoTo</span> <span style="color: #cc66cc;color:#800000;">0</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">If</span> fso Is <span style="color: #b1b100;">Nothing</span> <span style="color: #b1b100;">Then</span> <span style="color: #b1b100;">GoTo</span> ExitProc</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Dim</span> strFolder <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">String</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">strFolder = <span style="color: #ff0000;">"F:\MyFolder\"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">NextRow = <span style="color: #cc66cc;color:#800000;">1</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">For</span> Each filen In fso.<span style="color: #66cc66;">GetFolder</span><span style="color:#006600; font-weight:bold;">&#40;</span>strFolder<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Files</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; Cells<span style="color:#006600; font-weight:bold;">&#40;</span>NextRow, <span style="color: #cc66cc;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Value</span> = filen.<span style="color: #b1b100;">Name</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; NextRow = NextRow + <span style="color: #cc66cc;color:#800000;">1</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Next</span> filen</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">ExitProc:</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Set</span> fso = <span style="color: #b1b100;">Nothing</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">End</span> <span style="color: #b1b100;">Sub</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;You'll notice that Intellisense tries to help you when you enter the following statements relating to the Scripting Runtime:</p>
<div class="igBar"><span id="lvb-8"><a href="#" onclick="javascript:showPlainTxt('vb-8'); return false;">plain text version</a></span></div>
<div class="syntax_hilite"><span class="langName">VBA:</span>
<div id="vb-8">
<div class="vb">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Dim</span> fso <span style="color: #b1b100;">As</span> Scripting.<span style="color: #66cc66;">FileSystemObject</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Dim</span> filen <span style="color: #b1b100;">As</span> Scripting.<span style="color: #66cc66;">File</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Set</span> fso = <span style="color: #b1b100;">New</span> Scripting.<span style="color: #66cc66;">FileSystemObject</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">For</span> Each filen In fso.<span style="color: #66cc66;">GetFolder</span><span style="color:#006600; font-weight:bold;">&#40;</span>strFolder<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Files</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; Cells<span style="color:#006600; font-weight:bold;">&#40;</span>NextRow, <span style="color: #cc66cc;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Value</span> = filen.<span style="color: #b1b100;">Name</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;If you started out with the intention of writing late-bound code, and immediately started declaring your variables as Object, you would need to be very familiar with your objects to make sure you access their properties correctly. When its early bound, the computer (mostly) does that for you.</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;Now that we've got our early bound code written, and Intellisense has helped us all it can, we start changing the code so it's late bound. </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;As you recall from above, the first step is: <strong>Change all declarations from Outlook objects to the generic Object data type.</strong> So we'll change the declarations to Object for all of the Scripting objects.</p>
<div class="igBar"><span id="lvb-9"><a href="#" onclick="javascript:showPlainTxt('vb-9'); return false;">plain text version</a></span></div>
<div class="syntax_hilite"><span class="langName">VBA:</span>
<div id="vb-9">
<div class="vb">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Sub</span> ListFiles_2<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Dim</span> fso <span style="color: #b1b100;">As</span> Object</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Dim</span> filen <span style="color: #b1b100;">As</span> Object</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Dim</span> NextRow <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Long</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">On</span> <span style="color: #b1b100;">Error</span> <span style="color: #b1b100;">Resume</span> <span style="color: #b1b100;">Next</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Set</span> fso = <span style="color: #b1b100;">New</span> Scripting.<span style="color: #66cc66;">FileSystemObject</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">On</span> <span style="color: #b1b100;">Error</span> <span style="color: #b1b100;">GoTo</span> <span style="color: #cc66cc;color:#800000;">0</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">If</span> fso Is <span style="color: #b1b100;">Nothing</span> <span style="color: #b1b100;">Then</span> <span style="color: #b1b100;">GoTo</span> ExitProc</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Dim</span> strFolder <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">String</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">strFolder = <span style="color: #ff0000;">"F:\MyFolder\"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">NextRow = <span style="color: #cc66cc;color:#800000;">1</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">For</span> Each filen In fso.<span style="color: #66cc66;">GetFolder</span><span style="color:#006600; font-weight:bold;">&#40;</span>strFolder<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Files</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; Cells<span style="color:#006600; font-weight:bold;">&#40;</span>NextRow, <span style="color: #cc66cc;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Value</span> = filen.<span style="color: #b1b100;">Name</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; NextRow = NextRow + <span style="color: #cc66cc;color:#800000;">1</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Next</span> filen</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">ExitProc:</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Set</span> fso = <span style="color: #b1b100;">Nothing</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">End</span> <span style="color: #b1b100;">Sub</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;Even though we haven't fully converted the code yet, it will still work because we still have that reference to Microsoft Scripting Runtime. We want it to be fully late-bound, so we'll go to step 2: <strong>Change Set statements to GetObject or CreateObject</strong>. In addition, we'll remove that reference to Microsoft Scripting Runtime.</p>
<div class="igBar"><span id="lvb-10"><a href="#" onclick="javascript:showPlainTxt('vb-10'); return false;">plain text version</a></span></div>
<div class="syntax_hilite"><span class="langName">VBA:</span>
<div id="vb-10">
<div class="vb">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Sub</span> ListFiles_Final<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Dim</span> fso <span style="color: #b1b100;">As</span> Object</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Dim</span> filen <span style="color: #b1b100;">As</span> Object</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Dim</span> NextRow <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Long</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">On</span> <span style="color: #b1b100;">Error</span> <span style="color: #b1b100;">Resume</span> <span style="color: #b1b100;">Next</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Set</span> fso = <span style="color: #b1b100;">CreateObject</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">"Scripting.FileSystemObject"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">On</span> <span style="color: #b1b100;">Error</span> <span style="color: #b1b100;">GoTo</span> <span style="color: #cc66cc;color:#800000;">0</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">If</span> fso Is <span style="color: #b1b100;">Nothing</span> <span style="color: #b1b100;">Then</span> <span style="color: #b1b100;">GoTo</span> ExitProc</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Dim</span> strFolder <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">String</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">strFolder = <span style="color: #ff0000;">"F:\MyFolder\"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">NextRow = <span style="color: #cc66cc;color:#800000;">1</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">For</span> Each filen In fso.<span style="color: #66cc66;">GetFolder</span><span style="color:#006600; font-weight:bold;">&#40;</span>strFolder<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Files</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; Cells<span style="color:#006600; font-weight:bold;">&#40;</span>NextRow, <span style="color: #cc66cc;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Value</span> = filen.<span style="color: #b1b100;">Name</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; NextRow = NextRow + <span style="color: #cc66cc;color:#800000;">1</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Next</span> filen</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">ExitProc:</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Set</span> fso = <span style="color: #b1b100;">Nothing</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">End</span> <span style="color: #b1b100;">Sub</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;Steps 3 and 4 don't really apply to this example, but here's a small example if you were writing late-bound code for Outlook to create a MailItem.</p>
<p>Change:</p>
<div class="igBar"><span id="lvb-11"><a href="#" onclick="javascript:showPlainTxt('vb-11'); return false;">plain text version</a></span></div>
<div class="syntax_hilite"><span class="langName">VBA:</span>
<div id="vb-11">
<div class="vb">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Dim</span> olApp <span style="color: #b1b100;">As</span> Outlook.<span style="color: #66cc66;">Application</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Set</span> olApp = Outlook.<span style="color: #66cc66;">Application</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">olApp.<span style="color: #66cc66;">CreateItem</span><span style="color:#006600; font-weight:bold;">&#40;</span>olMailItem<span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>to:</p>
<div class="igBar"><span id="lvb-12"><a href="#" onclick="javascript:showPlainTxt('vb-12'); return false;">plain text version</a></span></div>
<div class="syntax_hilite"><span class="langName">VBA:</span>
<div id="vb-12">
<div class="vb">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Dim</span> olApp <span style="color: #b1b100;">As</span> Object</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Set</span> olApp = <span style="color: #b1b100;">CreateObject</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">"Outlook.Application"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">olApp.<span style="color: #66cc66;">CreateItem</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>According to the <a href="http://msdn.microsoft.com/en-us/library/aa219371(office.11).aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/msdn.microsoft.com');">list of Outlook 2003 Constants</a>, the value of olMailItem is 0 (zero), so the late-bound version uses that value instead of the constant.</p>
<p><br /><br /><br />
This post is from <a href="http://www.codeforexcelandoutlook.com/blog/" >Code For Excel And Outlook Blog</a></p>
<p><a href="http://www.codeforexcelandoutlook.com/blog/2008/11/take-advantage-of-intellisense-when-writing-late-bound-code/" >Take advantage of Intellisense when writing late bound code</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/codeforexcelandoutlook/kylx?a=nQzwn"><img src="http://feeds.feedburner.com/~f/codeforexcelandoutlook/kylx?i=nQzwn" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/codeforexcelandoutlook/kylx?a=4uvSN"><img src="http://feeds.feedburner.com/~f/codeforexcelandoutlook/kylx?i=4uvSN" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/codeforexcelandoutlook/kylx?a=0RLrn"><img src="http://feeds.feedburner.com/~f/codeforexcelandoutlook/kylx?i=0RLrn" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/codeforexcelandoutlook/kylx/~4/456056436" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codeforexcelandoutlook.com/blog/2008/11/take-advantage-of-intellisense-when-writing-late-bound-code/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Export Excel Range to a Picture File</title>
		<link>http://www.codeforexcelandoutlook.com/blog/2008/11/export-excel-range-to-a-picture-file/</link>
		<comments>http://www.codeforexcelandoutlook.com/blog/2008/11/export-excel-range-to-a-picture-file/#comments</comments>
		<pubDate>Fri, 14 Nov 2008 02:47:22 +0000</pubDate>
		<dc:creator>JP</dc:creator>
		
		<category><![CDATA[Excel]]></category>

		<category><![CDATA[chart]]></category>

		<category><![CDATA[ChartObject]]></category>

		<category><![CDATA[copy]]></category>

		<category><![CDATA[export]]></category>

		<category><![CDATA[gif]]></category>

		<category><![CDATA[range]]></category>

		<guid isPermaLink="false">http://www.codeforexcelandoutlook.com/blog/?p=347</guid>
		<description>&amp;#160;&amp;#160;&amp;#160;&amp;#160;If you ever needed to capture a range, for pasting into a document or email, you'll need to save it as an image first. If so, you might find this routine useful. It takes a contiguous range, starting in A1, and creates a GIF file with a snapshot of the range.
&amp;#160;&amp;#160;&amp;#160;&amp;#160;A temporary, intermediate chart is [...]</description>
			<content:encoded><![CDATA[<p>&nbsp;&nbsp;&nbsp;&nbsp;If you ever needed to capture a range, for pasting into a document or email, you'll need to save it as an image first. If so, you might find this routine useful. It takes a contiguous range, starting in A1, and creates a GIF file with a snapshot of the range.</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;A temporary, intermediate chart is used, so we can use its Export Method to create the GIF. The chart is then deleted. Through trial and error, I guessed at the appropriate chart size. I'm using Windows XP with a resolution of 1024x768, so you might need to adjust the constants' values as appropriate.</p>
<div class="igBar"><span id="lvb-17"><a href="#" onclick="javascript:showPlainTxt('vb-17'); return false;">plain text version</a></span></div>
<div class="syntax_hilite"><span class="langName">VBA:</span>
<div id="vb-17">
<div class="vb">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Sub</span> CopyRangeToGIF<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080;">' save a range from Excel as a picture</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Dim</span> rng <span style="color: #b1b100;">As</span> Excel.<span style="color: #66cc66;">Range</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Dim</span> cht <span style="color: #b1b100;">As</span> Excel.<span style="color: #66cc66;">ChartObject</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Const</span> strPath <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">String</span> = <span style="color: #ff0000;">"C:\"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Application.<span style="color: #66cc66;">ScreenUpdating</span> = <span style="color: #b1b100;">False</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Set</span> rng = Range<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">"A1"</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">CurrentRegion</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">rng.<span style="color: #66cc66;">CopyPicture</span> xlScreen, xlPicture</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Set</span> cht = ActiveSheet.<span style="color: #66cc66;">ChartObjects</span>.<span style="color: #66cc66;">Add</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">0</span>, <span style="color: #cc66cc;color:#800000;">0</span>, rng.<span style="color: #b1b100;">Width</span> + <span style="color: #cc66cc;color:#800000;">10</span>, rng.<span style="color: #66cc66;">Height</span> + <span style="color: #cc66cc;color:#800000;">10</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">cht.<span style="color: #66cc66;">Chart</span>.<span style="color: #66cc66;">Paste</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">cht.<span style="color: #66cc66;">Chart</span>.<span style="color: #66cc66;">Export</span> strPath &amp;amp; <span style="color: #ff0000;">"myfile.gif"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">cht.<span style="color: #66cc66;">Delete</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">ExitProc:</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Application.<span style="color: #66cc66;">ScreenUpdating</span> = <span style="color: #b1b100;">True</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Set</span> cht = <span style="color: #b1b100;">Nothing</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Set</span> rng = <span style="color: #b1b100;">Nothing</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">End</span> <span style="color: #b1b100;">Sub</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;This code will only create the picture. You'll probably want to do something with it.</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;If you want to add it to a Word document, try this:</p>
<div class="igBar"><span id="lvb-18"><a href="#" onclick="javascript:showPlainTxt('vb-18'); return false;">plain text version</a></span></div>
<div class="syntax_hilite"><span class="langName">VBA:</span>
<div id="vb-18">
<div class="vb">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Dim</span> wrdApp <span style="color: #b1b100;">As</span> Object <span style="color: #808080;">' Word.Application</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Dim</span> wrdDoc <span style="color: #b1b100;">As</span> Object <span style="color: #808080;">' Word.Document</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Set</span> wrdApp = <span style="color: #b1b100;">CreateObject</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">"Word.Application"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080;">'wrdApp.Visible = True</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Set</span> wrdDoc = wrdApp.<span style="color: #66cc66;">Documents</span>.<span style="color: #66cc66;">Add</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">wrdDoc.<span style="color: #66cc66;">InlineShapes</span>.<span style="color: #66cc66;">AddPicture</span> <span style="color: #ff0000;">"C:\myfile.gif"</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;To send it as an attachment in an Outlook email, try this:</p>
<div class="igBar"><span id="lvb-19"><a href="#" onclick="javascript:showPlainTxt('vb-19'); return false;">plain text version</a></span></div>
<div class="syntax_hilite"><span class="langName">VBA:</span>
<div id="vb-19">
<div class="vb">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Dim</span> olApp <span style="color: #b1b100;">As</span> Object <span style="color: #808080;">' Outlook.Application</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Dim</span> Msg <span style="color: #b1b100;">As</span> Object <span style="color: #808080;">' Outlook.MailItem</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Set</span> olApp = <span style="color: #b1b100;">CreateObject</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">"Outlook.Application"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Set</span> Msg = olApp.<span style="color: #66cc66;">CreateItem</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">With</span> Msg</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.<span style="color: #b1b100;">To</span> = <span style="color: #ff0000;">"coworker@mycompany.com"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.<span style="color: #66cc66;">Body</span> = <span style="color: #ff0000;">"Check out this range!"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.<span style="color: #66cc66;">Attachments</span>.<span style="color: #66cc66;">Add</span> <span style="color: #ff0000;">"c:\myfile.gif"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.<span style="color: #66cc66;">Send</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">End</span> <span style="color: #b1b100;">With</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;If you want to send the range in the body of an email, you're better off using the technique described <a href="http://www.rondebruin.nl/mail/folder3/mail4.htm" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.rondebruin.nl');">here</a>.</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;And last but not least, if you wanted the picture in a PowerPoint slide, this code will create a new presentation and insert the picture into a slide. Unlike the code snippets above for Outlook and Word, which use the saved GIF copy, for PowerPoint you'll need to call this code right after executing the Range.CopyPicture Method.</p>
<div class="igBar"><span id="lvb-20"><a href="#" onclick="javascript:showPlainTxt('vb-20'); return false;">plain text version</a></span></div>
<div class="syntax_hilite"><span class="langName">VBA:</span>
<div id="vb-20">
<div class="vb">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Dim</span> pptApp <span style="color: #b1b100;">As</span> Object <span style="color: #808080;">' PowerPoint.Application</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Dim</span> pptPres <span style="color: #b1b100;">As</span> Object <span style="color: #808080;">' PowerPoint.Presentation</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Dim</span> pptSlide <span style="color: #b1b100;">As</span> Object <span style="color: #808080;">' PowerPoint.Slide</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Set</span> pptApp = <span style="color: #b1b100;">CreateObject</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">"PowerPoint.Application"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Set</span> pptPres = pptApp.<span style="color: #66cc66;">Presentations</span>.<span style="color: #66cc66;">Add</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Set</span> pptSlide = pptPres.<span style="color: #66cc66;">Slides</span>.<span style="color: #66cc66;">Add</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">pptSlide.<span style="color: #66cc66;">Shapes</span>.<span style="color: #66cc66;">Paste</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><strong>[Update 11/14/2008]: CopyRangeToGIF sub was updated based on suggestion from Jon Peltier. No need for complicated calculations!</strong></p>
<p><br /><br /><br />
This post is from <a href="http://www.codeforexcelandoutlook.com/blog/" >Code For Excel And Outlook Blog</a></p>
<p><a href="http://www.codeforexcelandoutlook.com/blog/2008/11/export-excel-range-to-a-picture-file/" >Export Excel Range to a Picture File</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/codeforexcelandoutlook/kylx?a=ufDpn"><img src="http://feeds.feedburner.com/~f/codeforexcelandoutlook/kylx?i=ufDpn" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/codeforexcelandoutlook/kylx?a=5FycN"><img src="http://feeds.feedburner.com/~f/codeforexcelandoutlook/kylx?i=5FycN" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/codeforexcelandoutlook/kylx?a=LdN0n"><img src="http://feeds.feedburner.com/~f/codeforexcelandoutlook/kylx?i=LdN0n" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/codeforexcelandoutlook/kylx/~4/452469371" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codeforexcelandoutlook.com/blog/2008/11/export-excel-range-to-a-picture-file/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Shipment Tracking Userform for batch processing</title>
		<link>http://www.codeforexcelandoutlook.com/blog/2008/11/shipment-tracking-userform-for-batch-processing/</link>
		<comments>http://www.codeforexcelandoutlook.com/blog/2008/11/shipment-tracking-userform-for-batch-processing/#comments</comments>
		<pubDate>Thu, 13 Nov 2008 01:39:49 +0000</pubDate>
		<dc:creator>JP</dc:creator>
		
		<category><![CDATA[AddIns]]></category>

		<category><![CDATA[Excel]]></category>

		<category><![CDATA[add-in]]></category>

		<category><![CDATA[shipment tracking]]></category>

		<category><![CDATA[ShipTrack]]></category>

		<category><![CDATA[userform]]></category>

		<guid isPermaLink="false">http://www.codeforexcelandoutlook.com/blog/?p=336</guid>
		<description>&amp;#160;&amp;#160;&amp;#160;&amp;#160;In my previous post Shipment Tracking Add-In for Excel I introduced an add-in UDF for tracking package shipments from UPS, DHL and FedEx. A few more caveats about that function:

It appears to only work for domestic (U.S.) shipments.
It does work for FedEx tracking numbers, but only the 12-digit version. There is a 22-digit version of [...]</description>
			<content:encoded><![CDATA[<p>&nbsp;&nbsp;&nbsp;&nbsp;In my previous post <a href="http://www.codeforexcelandoutlook.com/blog/2008/11/shipment-tracking-add-in-for-excel/" >Shipment Tracking Add-In for Excel</a> I introduced an add-in UDF for tracking package shipments from UPS, DHL and FedEx. A few more caveats about that function:</p>
<ul>
<li>It appears to only work for domestic (U.S.) shipments.</li>
<li>It <em>does</em> work for FedEx tracking numbers, but only the 12-digit version. There is a 22-digit version of the tracking number which you need to pass to the function directly as an argument (not as a cell reference).</li>
</ul>
<p>&nbsp;&nbsp;&nbsp;&nbsp;If anyone would like me to include international shipments, I will certainly check out that functionality and see if it is possible. For more information in general about the function, check out the post from the link above.</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;I've completed a userform-based add-in that uses the functionality from the ShipTrack add-in. It employs a batch feature which allows you to track packages in bulk.</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;In order to use the UI, you will need to install the ShipTrack add-in from my previous post, in order for the new add-in to access the previous add-in's functions. Here is a link to the add-in: <a href="http://www.codeforexcelandoutlook.com/wkbks/ShipTrack.zip" onclick="javascript:pageTracker._trackPageview('/downloads/wkbks/ShipTrack.zip');">ShipTrack Add-in</a>.</p>
<p><strong>You must install the ShipTrack add-in before installing the new UI add-in. Also, both add-ins must be in the same folder.</strong></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;And of course here is a link to the new add-in: <a href="http://www.codeforexcelandoutlook.com/wkbks/ShipTrackUI.zip" onclick="javascript:pageTracker._trackPageview('/downloads/wkbks/ShipTrackUI.zip');">ShipTrackUI Add-in</a></p>
<p><strong>Requires MSXML 6.0 as follows: c:\windows\system32\msxml6.dll</strong></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;Just like the ShipTrack add-in, you'll need to install this one in the traditional way (go to Tools>Add-Ins and browse for the XLA file). After installing the ShipTrackUI add-in, you will see an addition to your Tools Menu: Batch Shipment Tracking. Here is a screenshot of the form that appears when you select that option:</p>
<p><a href="http://www.codeforexcelandoutlook.com/blog/wp-content/uploads/2008/11/shiptrack-userform.jpg" onclick="javascript:pageTracker._trackPageview('/downloads/blog/wp-content/uploads/2008/11/shiptrack-userform.jpg');"><img class="alignnone size-medium wp-image-337" title="shiptrack-userform" src="http://www.codeforexcelandoutlook.com/blog/wp-content/uploads/2008/11/shiptrack-userform-300x164.jpg" alt="shiptrack-userform-300x164" width="300" height="164" /></a></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;Click 'Open File' to select a file for processing. Your target worksheet must be formatted with two columns: A list of tracking numbers in column A (with header in A1) and a list of the carriers in column B (with header in B1). There cannot be any blank rows or missing data. Here is a sample:</p>
<p><a href="http://www.codeforexcelandoutlook.com/blog/wp-content/uploads/2008/11/shiptrackui-test-file.jpg" onclick="javascript:pageTracker._trackPageview('/downloads/blog/wp-content/uploads/2008/11/shiptrackui-test-file.jpg');"><img class="alignnone size-medium wp-image-338" title="shiptrackui-test-file" src="http://www.codeforexcelandoutlook.com/blog/wp-content/uploads/2008/11/shiptrackui-test-file-251x300.jpg" alt="shiptrackui-test-file-251x300" width="251" height="300" /></a></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;Click 'Submit' to begin processing. There is a label control on the form which updates to show you progress. After it is finished, the form looks like this:</p>
<p><a href="http://www.codeforexcelandoutlook.com/blog/wp-content/uploads/2008/11/shiptrack-userform2.jpg" onclick="javascript:pageTracker._trackPageview('/downloads/blog/wp-content/uploads/2008/11/shiptrack-userform2.jpg');"><img class="alignnone size-medium wp-image-340" title="shiptrack-userform2" src="http://www.codeforexcelandoutlook.com/blog/wp-content/uploads/2008/11/shiptrack-userform2-300x164.jpg" alt="shiptrack-userform2-300x164" width="300" height="164" /></a></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;And your spreadsheet will be updated in column C with the information provided by the appropriate website:</p>
<p><a href="http://www.codeforexcelandoutlook.com/blog/wp-content/uploads/2008/11/shiptrackui-test-file2.jpg" onclick="javascript:pageTracker._trackPageview('/downloads/blog/wp-content/uploads/2008/11/shiptrackui-test-file2.jpg');"><img class="alignnone size-medium wp-image-341" title="shiptrackui-test-file2" src="http://www.codeforexcelandoutlook.com/blog/wp-content/uploads/2008/11/shiptrackui-test-file2-265x300.jpg" alt="shiptrackui-test-file2-265x300" width="265" height="300" /></a></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;The form is very basic, so please let me know if you run into any runtime errors or other problems. Your feedback is critical!</p>
<p>Enjoy,<br />
JP</p>
<p><br /><br /><br />
This post is from <a href="http://www.codeforexcelandoutlook.com/blog/" >Code For Excel And Outlook Blog</a></p>
<p><a href="http://www.codeforexcelandoutlook.com/blog/2008/11/shipment-tracking-userform-for-batch-processing/" >Shipment Tracking Userform for batch processing</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/codeforexcelandoutlook/kylx?a=IJvgn"><img src="http://feeds.feedburner.com/~f/codeforexcelandoutlook/kylx?i=IJvgn" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/codeforexcelandoutlook/kylx?a=bLPRN"><img src="http://feeds.feedburner.com/~f/codeforexcelandoutlook/kylx?i=bLPRN" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/codeforexcelandoutlook/kylx?a=UNRVn"><img src="http://feeds.feedburner.com/~f/codeforexcelandoutlook/kylx?i=UNRVn" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/codeforexcelandoutlook/kylx/~4/451304489" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codeforexcelandoutlook.com/blog/2008/11/shipment-tracking-userform-for-batch-processing/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Shipment Tracking Add-In for Excel</title>
		<link>http://www.codeforexcelandoutlook.com/blog/2008/11/shipment-tracking-add-in-for-excel/</link>
		<comments>http://www.codeforexcelandoutlook.com/blog/2008/11/shipment-tracking-add-in-for-excel/#comments</comments>
		<pubDate>Fri, 07 Nov 2008 17:20:21 +0000</pubDate>
		<dc:creator>JP</dc:creator>
		
		<category><![CDATA[Excel]]></category>

		<category><![CDATA[UDF]]></category>

		<category><![CDATA[add-in]]></category>

		<category><![CDATA[CreateObject]]></category>

		<category><![CDATA[MacroOptions]]></category>

		<category><![CDATA[shipment]]></category>

		<category><![CDATA[tracking]]></category>

		<category><![CDATA[XMLHTTP]]></category>

		<guid isPermaLink="false">http://www.codeforexcelandoutlook.com/blog/?p=290</guid>
		<description>&amp;#160;&amp;#160;&amp;#160;&amp;#160;Have you ever wanted to incorporate shipment tracking into your spreadsheet application?
&amp;#160;&amp;#160;&amp;#160;&amp;#160;I've just completed another add-in for Excel -- this one is a UDF that lets you track shipments you've sent via DHL, UPS or FedEx.
To install:
&amp;#160;&amp;#160;&amp;#160;&amp;#160;First, download and save the add-in somewhere special. Here is the file: Shipment Tracking Add-In For Excel
&amp;#160;&amp;#160;&amp;#160;&amp;#160;Start Excel and [...]</description>
			<content:encoded><![CDATA[<p>&nbsp;&nbsp;&nbsp;&nbsp;Have you ever wanted to incorporate shipment tracking into your spreadsheet application?</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;I've just completed another add-in for Excel -- this one is a UDF that lets you track shipments you've sent via DHL, UPS or FedEx.</p>
<h3>To install:</h3>
<p>&nbsp;&nbsp;&nbsp;&nbsp;First, download and save the add-in somewhere special. Here is the file: <a href="http://www.codeforexcelandoutlook.com/wkbks/ShipTrack.zip" onclick="javascript:pageTracker._trackPageview('/downloads/wkbks/ShipTrack.zip');">Shipment Tracking Add-In For Excel</a></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;Start Excel and go to Tools &gt; Add-Ins... and browse to the folder where you placed the file. <strong>Don't double-click on the file to install it.</strong> (I wrote the add-in to allow you to do this, but the functionality doesn't seem to be working as intended, so it's better to just install it the way you are supposed to install add-ins anyway.)</p>
<p><a href="http://www.codeforexcelandoutlook.com/blog/wp-content/uploads/2008/11/addindialogbox.jpg" onclick="javascript:pageTracker._trackPageview('/downloads/blog/wp-content/uploads/2008/11/addindialogbox.jpg');"><img src="http://www.codeforexcelandoutlook.com/blog/wp-content/uploads/2008/11/addindialogbox-263x300.jpg" alt="addindialogbox-263x300" title="Add-Ins Dialog Box" width="263" height="300" class="alignnone size-medium wp-image-292" /></a></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;After installing the add-in, you'll have an additional function in the DDE/External category. You can access the function the same way as any other function in Excel.</p>
<ul>
<li>In the worksheet, press Shift-F3, type "ShipTrack" or choose <strong>DDE/External</strong> in the "Select a category" dropdown</li>
<li>Start typing "=ShipTrack(" in a worksheet cell</li>
<li>Go to Insert>Function or click <strong>Insert Function</strong> next to the formula bar.</li>
</ul>
<p><a href="http://www.codeforexcelandoutlook.com/blog/wp-content/uploads/2008/11/ddeexternalfunctions.jpg" onclick="javascript:pageTracker._trackPageview('/downloads/blog/wp-content/uploads/2008/11/ddeexternalfunctions.jpg');"><img src="http://www.codeforexcelandoutlook.com/blog/wp-content/uploads/2008/11/ddeexternalfunctions-300x255.jpg" alt="ddeexternalfunctions-300x255" title="Insert Function Dialog Box" width="300" height="255" class="alignnone size-medium wp-image-296" /></a></p>
<h3>Usage:</h3>
<p><strong>=ShipTrack(<em>Tracking_Number</em>,<em>Carrier</em>)</strong></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;Where <strong><em>Tracking_Number</em></strong> is a string literal in quotes, or a cell reference which contains a UPS or DHL tracking number, and <strong><em>Carrier</em></strong> is a string literal or cell reference contains the name of the carrier (either "UPS" or "DHL" or "FedEx"). These parameters can also be entered directly into the function, instead of as a cell reference.</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;FedEx tracking numbers are too long to fit in a cell (they get truncated after 15 digits) <strong>so you'll need to enter them directly into the formula as such</strong>:</p>
<p><strong>=ShipTrack("093974897039389749","FedEx")</strong></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;The following conditions will cause an error message:</p>
<ul>
<li>If you (accidently) try to pass a FedEx number to the function as a cell reference;</li>
<li>If you (accidently) enter blanks or leave out any of the arguments</li>
<li>If you pass an unknown or misspelled carrier name;</li>
<li>If the tracking number cannot be found by the carrier, for example if it is too old or invalid;</il>
<li>If one of the three carriers changes their website and the functionality breaks.</li>
<li>If something else happens that I didn't plan for <img src='http://www.codeforexcelandoutlook.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' title="icon wink photo" /> </li>
</ul>
<p>&nbsp;&nbsp;&nbsp;&nbsp;If you do get an error message, you'll need to check which of the above conditions occurred. You might have to manually track your package on the carrier's website and see what happens.</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;The carrier name is not case sensitive, so you can use all lower case, CamelCase, aNy CaSe YoU wANT. <img src='http://www.codeforexcelandoutlook.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' title="icon smile photo" /> </p>
<h3>How it works:</h3>
<p>&nbsp;&nbsp;&nbsp;&nbsp;The function uses a late-bound XMLHTTP object to perform a web query of the given tracking number. It is <strong><em>much</em></strong> faster than using the Shdocvw.InternetExplorer object, but there is still a slight delay because it is late-bound.</p>
<p><strong>Requires MSXML 6.0 as follows: c:\windows\system32\msxml6.dll</strong></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;It is volatile so it will recalculate repeatedly as the worksheet is used. I don't recommend setting calculation to manual, so you should delete the formula after using it, or you can comment it out in the worksheet by editing the cell (press F2, then Home) and pre-pending an apostrophe, so the cell would look like <strong>'=ShipTrack(A1,B1)</strong>. Just remove the apostrophe to re-enter the formula.</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;I had a limited number of tracking numbers to use to test out the functionality, <a href="http://www.codeforexcelandoutlook.com/blog/contact/" >please test it out and let me know if you find any bugs</a>, tracking numbers errors where you go to the site and the tracking number was found, etc. </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;I'm also planning a userform version, perhaps with a batch upload feature, so stay tuned! </p>
<p><strong>[Update 11/12/2008]: I made it to Pointy Haired Dilbert's Excel Links of the Week, again! <a href="http://chandoo.org/wp/2008/11/10/excel-links-download-templates-edition/" onclick="javascript:pageTracker._trackPageview('/outbound/article/chandoo.org');">Check out Chandoo's post here</a>.</strong> Also I should mention that DHL is ceasing U.S. domestic express service on January 30, 2009. So if you or your company is using DHL (and you didn't know by now), you probably want to start looking at other options.</p>
<p>And I would also like to add that FedEx tracking numbers also have a 12 digit format which will work in the formula as described for UPS and DHL. If you use that number instead, you can put it in a cell and pass the cell reference to the ShipTrack function.</p>
<p>--JP</p>
<p><br /><br /><br />
This post is from <a href="http://www.codeforexcelandoutlook.com/blog/" >Code For Excel And Outlook Blog</a></p>
<p><a href="http://www.codeforexcelandoutlook.com/blog/2008/11/shipment-tracking-add-in-for-excel/" >Shipment Tracking Add-In for Excel</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/codeforexcelandoutlook/kylx?a=E6COn"><img src="http://feeds.feedburner.com/~f/codeforexcelandoutlook/kylx?i=E6COn" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/codeforexcelandoutlook/kylx?a=zE0QN"><img src="http://feeds.feedburner.com/~f/codeforexcelandoutlook/kylx?i=zE0QN" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/codeforexcelandoutlook/kylx?a=pTQKn"><img src="http://feeds.feedburner.com/~f/codeforexcelandoutlook/kylx?i=pTQKn" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/codeforexcelandoutlook/kylx/~4/445703036" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codeforexcelandoutlook.com/blog/2008/11/shipment-tracking-add-in-for-excel/feed/</wfw:commentRss>
		</item>
		<item>
		<title>A simple formula trick to visualize your errors</title>
		<link>http://www.codeforexcelandoutlook.com/blog/2008/11/a-simple-formula-trick-to-visualize-your-errors/</link>
		<comments>http://www.codeforexcelandoutlook.com/blog/2008/11/a-simple-formula-trick-to-visualize-your-errors/#comments</comments>
		<pubDate>Mon, 03 Nov 2008 18:49:15 +0000</pubDate>
		<dc:creator>JP</dc:creator>
		
		<category><![CDATA[Excel]]></category>

		<category><![CDATA[Formulas]]></category>

		<category><![CDATA[conditional formatting]]></category>

		<category><![CDATA[SUMPRODUCT]]></category>

		<category><![CDATA[wingdings]]></category>

		<guid isPermaLink="false">http://www.codeforexcelandoutlook.com/blog/?p=260</guid>
		<description>&amp;#160;&amp;#160;&amp;#160;&amp;#160;Here's a neat trick I use to make spotting worksheet errors very simple.
&amp;#160;&amp;#160;&amp;#160;&amp;#160;Wrap your formula in an IF statement that returns the letter "J" if True, or the letter "L" if False, and change the cell's font to Wingdings.
&amp;#160;&amp;#160;&amp;#160;&amp;#160;In the Wingdings font, "J" is a smiley face  and "L" is a frown  . [...]</description>
			<content:encoded><![CDATA[<p>&nbsp;&nbsp;&nbsp;&nbsp;Here's a neat trick I use to make spotting worksheet errors very simple.</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;Wrap your formula in an IF statement that returns the letter "J" if <strong>True</strong>, or the letter "L" if <strong>False</strong>, and change the cell's font to Wingdings.</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;In the Wingdings font, "J" is a smiley face <img src='http://www.codeforexcelandoutlook.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' title="icon smile photo" /> and "L" is a frown <img src='http://www.codeforexcelandoutlook.com/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' title="icon sad photo" /> . So you (or your end users) can get an immediate visual clue as to the success or failure of their formula. It's low-tech but very effective.</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;For example, don't just write</p>
<p><strong>=A1=A2</strong></p>
<p>to compare two cells (which just returns a boring TRUE or FALSE to the target cell). Instead, use</p>
<p><strong>=IF(A1=A2,"J","L")</strong></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;<strong>Don't forget to change the cell's font to Wingdings</strong>. Even better, blow it up to a size 20 and make it bold to really stand out. <img src='http://www.codeforexcelandoutlook.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' title="icon wink photo" /> </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;Let's take it even further with conditional formatting. Set up your target cell's conditional formatting as follows:</p>
<p><a href="http://www.codeforexcelandoutlook.com/blog/wp-content/uploads/2008/11/condformat1.jpg" onclick="javascript:pageTracker._trackPageview('/downloads/blog/wp-content/uploads/2008/11/condformat1.jpg');"><img src="http://www.codeforexcelandoutlook.com/blog/wp-content/uploads/2008/11/condformat1-300x144.jpg" alt="condformat1-300x144" title="condformat1" width="300" height="144" class="alignnone size-medium wp-image-266" /></a></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;Now your smiley face is a <span style="color:#339900;">happy green color</span>, and the bad formulas get an <span style="color:#FF3333;">ugly red color</span>. Perfect for those <a rel="nofollow" href="http://www.paulgraham.com/icad.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.paulgraham.com');">PHBs</a> who can't be bothered to read a spreadsheet, so they can get a color-coded view. I hope that doesn't dissuade you from using this technique in your own work. <img src='http://www.codeforexcelandoutlook.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' title="icon wink photo" /> </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;Here's a related topic for which you can use similar techniques: <a rel="nofollow" href="http://j-walk.com/ss/excel/usertips/tip052.htm" onclick="javascript:pageTracker._trackPageview('/outbound/article/j-walk.com');">Creating a non-graphic chart directly in a range</a></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;Now if I want a count of formula errors, I just use the COUNTIF formula as follows. Assuming I filled down my IF formula down an unspecified number of rows in column B,</p>
<p><strong>="Raw errors: "&#038;COUNTIF(B:B,"L")</strong></p>
<p>would return the number of sad faces (i.e. FALSE returns) in that column.</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;Typically, though, I'll use the IF formula to evaluate multiple cells in the same row. In that case, I might want to know how many <em>full row errors</em> there are; in other words, how many rows had all of their formulas return FALSE. I'll use SUMPRODUCT for this.</p>
<p><strong>="Full row errors: "&#038;SUMPRODUCT((B2:B5000="L")*(C2:C5000="L"))</strong></p>
<p>or</p>
<p><strong>="Full row errors: "&#038;SUMPRODUCT(--(B2:B5000="L")*--(C2:C5000="L"))</strong></p>
<p>or </p>
<p><strong>="Full row errors: "&#038;SUMPRODUCT(N(B2:B5000="L")*(N(C2:C5000="L")))</strong></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;These formulas will compare each pair of cells (B2 &#038; C2, B3 &#038; C3, etc), evaluate whether each one equals "L" (1 for TRUE, 0 for FALSE) and multiplies the values together. Only the rows where both expressions evaluate to TRUE will add 1 to the total. </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;For SUMPRODUCT you can't use full column references (in Excel 2003), so I just chose an arbitrarily large range. Adjust as needed. The only difference with the last two formulas is the double unary (--, that's two hyphens) or N() function, which might be required to convert text to values, but for the most part only useful to achieve "Excel-god" status in your office. <img src='http://www.codeforexcelandoutlook.com/blog/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' title="icon cool photo" /> </p>
<p>Enjoy,<br />
JP</p>
<p><br /><br /><br />
This post is from <a href="http://www.codeforexcelandoutlook.com/blog/" >Code For Excel And Outlook Blog</a></p>
<p><a href="http://www.codeforexcelandoutlook.com/blog/2008/11/a-simple-formula-trick-to-visualize-your-errors/" >A simple formula trick to visualize your errors</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/codeforexcelandoutlook/kylx?a=emAqn"><img src="http://feeds.feedburner.com/~f/codeforexcelandoutlook/kylx?i=emAqn" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/codeforexcelandoutlook/kylx?a=jivwN"><img src="http://feeds.feedburner.com/~f/codeforexcelandoutlook/kylx?i=jivwN" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/codeforexcelandoutlook/kylx?a=VihXn"><img src="http://feeds.feedburner.com/~f/codeforexcelandoutlook/kylx?i=VihXn" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/codeforexcelandoutlook/kylx/~4/441275231" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codeforexcelandoutlook.com/blog/2008/11/a-simple-formula-trick-to-visualize-your-errors/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
