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

<channel>
	<title>Saved for later reference &#187; Lars Erik Jordet</title>
	<atom:link href="http://www.lejordet.com/author/lejordet/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lejordet.com</link>
	<description>online repository of stuff I had to google for hours to figure out</description>
	<lastBuildDate>Tue, 06 Jul 2010 13:26:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Active Directory user GUID</title>
		<link>http://www.lejordet.com/2010/07/active-directory-user-guid/</link>
		<comments>http://www.lejordet.com/2010/07/active-directory-user-guid/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 13:26:36 +0000</pubDate>
		<dc:creator>Lars Erik Jordet</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[quick]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[ad]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[ps]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.lejordet.com/?p=106</guid>
		<description><![CDATA[PowerShell oneliner to get AD user GUID]]></description>
			<content:encoded><![CDATA[<p>I found 
<a  href="http://msgoodies.blogspot.com/2008/02/get-active-directory-object-guid-one.html" onclick="javascript:pageTracker._trackPageview('/external/msgoodies.blogspot.com/2008/02/get-active-directory-object-guid-one.html');" >this page</a> which contains an old oneliner to get a user GUID in PowerShell &#8211; but sadly it doesn&#8217;t work anymore.</p>
<p>After some tricking around, I found the following to work:</p>
<div class="codecolorer-container powershell blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="powershell codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">new-object</span> Guid<span style="color: #000000;">&#40;</span><span style="color: pink;">,</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span>directoryservices.directorysearcher<span style="color: #000000;">&#93;</span> <span style="color: #800000;">&quot;(samaccountname=theuser)&quot;</span><span style="color: #000000;">&#41;</span>.findall<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">0</span><span style="color: #000000;">&#93;</span>.properties<span style="color: #000000;">&#91;</span><span style="color: #800000;">&quot;objectguid&quot;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">0</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>.ToString<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://www.lejordet.com/2010/07/active-directory-user-guid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MS Dynamics CRM installation: ASP.NET 2.0 is not installed</title>
		<link>http://www.lejordet.com/2010/07/ms-dynamics-crm-installation-asp-net-2-0-is-not-installed/</link>
		<comments>http://www.lejordet.com/2010/07/ms-dynamics-crm-installation-asp-net-2-0-is-not-installed/#comments</comments>
		<pubDate>Mon, 05 Jul 2010 12:46:22 +0000</pubDate>
		<dc:creator>Lars Erik Jordet</dc:creator>
				<category><![CDATA[quick]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[.net2.0]]></category>
		<category><![CDATA[dynamics]]></category>
		<category><![CDATA[IIS6]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.lejordet.com/?p=109</guid>
		<description><![CDATA[What to do if MS Dynamics CRM installation reports "ASP.NET 2.0 is not installed" after you've installed .NET 4.0]]></description>
			<content:encoded><![CDATA[<p>I got this error message on a server while installing Dynamics. At first I thought the problem was that my IIS is running 64 bit .NET 2.0 (I&#8217;ve had problems with that in the past), but it turns out that the actual problem is that .NET 4.0 was installed.</p>
<p>
<a  href="http://crm.vdsnickt.eu/2010/05/ms-crm-4-0-setup-error-asp-net-is-not-installed/" onclick="javascript:pageTracker._trackPageview('/external/crm.vdsnickt.eu/2010/05/ms-crm-4-0-setup-error-asp-net-is-not-installed/');" >This guy</a> figured out what the problem is: The installer checks for a specific filter in the IIS settings, which doesn&#8217;t exist when .NET 4.0 has been installed.</p>
<p>I&#8217;ll repeat the fix here, hopefully making this a bit more &#8220;discoverable&#8221; by search engines (searching the exact error message gave me nothing helpful, just tips about running <span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; line-height: 18px; font-size: 12px; white-space: pre;">aspnet_regiis.exe -i <span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; line-height: 19px; white-space: normal; font-size: 13px;">repeatedly):</span></span></p>
<p>In IIS Manager, right click Web Sites, and select Properties.</p>
<p>Under ISAPI Filters, Add a new filter you call ASP.NET_2.0.50727, pointing to C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\aspnet_filter.dll (assuming 64 bit server, otherwise substitute Framework for Framework64).</p>
<p>Dynamics should now install without issue.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lejordet.com/2010/07/ms-dynamics-crm-installation-asp-net-2-0-is-not-installed/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>&#8220;Couldn&#8217;t generate the upgrade script.&#8221; for version C.0.8.40 of MS SQL Reporting Services</title>
		<link>http://www.lejordet.com/2010/07/couldnt-generate-the-upgrade-script-for-version-c-0-8-40-of-ms-sql-reporting-services/</link>
		<comments>http://www.lejordet.com/2010/07/couldnt-generate-the-upgrade-script-for-version-c-0-8-40-of-ms-sql-reporting-services/#comments</comments>
		<pubDate>Mon, 05 Jul 2010 08:51:42 +0000</pubDate>
		<dc:creator>Lars Erik Jordet</dc:creator>
				<category><![CDATA[quick]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[mssql]]></category>
		<category><![CDATA[mssql2005]]></category>
		<category><![CDATA[win32]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.lejordet.com/?p=104</guid>
		<description><![CDATA[The error message &#8220;Couldn&#8217;t generate the upgrade script&#8221; pops up during configuration of Reporting Services for MS SQL Server 2005, if you install reporting services after installing a service pack &#8211; in my case Reporting Services was installed as SP1, while the main SQL Server 2005 install was updated to SP3. Reinstalling SQL Server 2005 SP3 [...]]]></description>
			<content:encoded><![CDATA[<p>The error message &#8220;Couldn&#8217;t generate the upgrade script&#8221; pops up during configuration of Reporting Services for MS SQL Server 2005, if you install reporting services after installing a service pack &#8211; in my case Reporting Services was installed as SP1, while the main SQL Server 2005 install was updated to SP3.</p>
<p>Reinstalling 
<a  href="http://www.microsoft.com/downloads/details.aspx?FamilyID=ae7387c3-348c-4faa-8ae5-949fdfbe59c4&amp;displaylang=en" onclick="javascript:pageTracker._trackPageview('/external/www.microsoft.com/downloads/details.aspx');" >SQL Server 2005 SP3</a> fixed it.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.lejordet.com%2F2010%2F07%2Fcouldnt-generate-the-upgrade-script-for-version-c-0-8-40-of-ms-sql-reporting-services%2F&amp;linkname=%26%238220%3BCouldn%26%238217%3Bt%20generate%20the%20upgrade%20script.%26%238221%3B%20for%20version%20C.0.8.40%20of%20MS%20SQL%20Reporting%20Services"><img src="http://www.lejordet.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.lejordet.com/2010/07/couldnt-generate-the-upgrade-script-for-version-c-0-8-40-of-ms-sql-reporting-services/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mercurial module for Python 2.6/Win32</title>
		<link>http://www.lejordet.com/2010/06/mercurial-module-for-python-2-6win32/</link>
		<comments>http://www.lejordet.com/2010/06/mercurial-module-for-python-2-6win32/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 09:44:43 +0000</pubDate>
		<dc:creator>Lars Erik Jordet</dc:creator>
				<category><![CDATA[compiling]]></category>
		<category><![CDATA[packages]]></category>
		<category><![CDATA[compile]]></category>
		<category><![CDATA[hg]]></category>
		<category><![CDATA[mercurial]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[python2.6]]></category>
		<category><![CDATA[trac]]></category>
		<category><![CDATA[win32]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.lejordet.com/?p=102</guid>
		<description><![CDATA[Precompiled Mercurial 1.5.4 for Python 2.6]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve compiled Mercurial 1.5.4 for Python 2.6, following 
<a  href="http://mercurial.selenic.com/wiki/WindowsInstall" onclick="javascript:pageTracker._trackPageview('/external/mercurial.selenic.com/wiki/WindowsInstall');" >this guide</a>, and uploaded it here, since I guess it&#8217;ll be useful for later:</p>
<p>
<a  href="/files/python/mercurial-1.5.4.win32-py2.6.exe" onclick="javascript:pageTracker._trackPageview('/downloads/files/python/mercurial-1.5.4.win32-py2.6.exe');" >mercurial-1.5.4.win32-py2.6.exe</a></p>
<p>I use it for 
<a  href="http://trac.edgewall.org" onclick="javascript:pageTracker._trackPageview('/external/trac.edgewall.org');" >Trac 0.12</a> in a multi-repository setting, so we can keep our old SVN repo while having some of the larger projects on Hg.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lejordet.com/2010/06/mercurial-module-for-python-2-6win32/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making a Trac install work on Apache 2.2/Python 2.6/win32, 2010 edition</title>
		<link>http://www.lejordet.com/2010/01/making-a-trac-install-work-on-apache-2-2python-2-6win32-2010-edition/</link>
		<comments>http://www.lejordet.com/2010/01/making-a-trac-install-work-on-apache-2-2python-2-6win32-2010-edition/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 11:14:25 +0000</pubDate>
		<dc:creator>Lars Erik Jordet</dc:creator>
				<category><![CDATA[windows]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[python2.6]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[trac]]></category>
		<category><![CDATA[win32]]></category>

		<guid isPermaLink="false">http://www.lejordet.com/?p=98</guid>
		<description><![CDATA[A year ago making Trac work on Python 2.6/win32 was a lot of work, including having to compile your own Python SVN bindings. This is an update of that old article assuming the usage of pre-built PySVN bindings.]]></description>
			<content:encoded><![CDATA[<p><span style="font-weight: normal;">About 10 months ago I wrote a 
<a  href="http://www.lejordet.com/2009/03/making-a-trac-install-work-on-apache-22python-26win32/">short article</a> on getting 
<a title="Trac"  href="http://trac.edgewall.org/" onclick="javascript:pageTracker._trackPageview('/external/trac.edgewall.org/');" >Trac</a> to work on Python 2.6 and Windows. Recently I updated the install, and took a look at how the situation is now.</span></p>
<p>This guide assumes you have a working install of Trac on Python 2.5/mod_python/Apache2.2 already, as described in the 
<a  href="http://trac.edgewall.org/wiki/TracInstall" onclick="javascript:pageTracker._trackPageview('/external/trac.edgewall.org/wiki/TracInstall');" >Trac install guide</a>, and that 
<a  href="http://www.python.org/download/releases/2.6.4/" onclick="javascript:pageTracker._trackPageview('/external/www.python.org/download/releases/2.6.4/');" >Python 2.6</a> is installed.</p>
<p>What needs to be done:</p>
<ul>
<li>Install Python 2.6 and Trac for 2.6</li>
<li>Build a new version of mod_python</li>
<li>Optionally Replace Apache DLLs (mostly if you followed my previous guide)</li>
</ul>
<h2>Required software</h2>
<p>You&#8217;ll need 
<a  href="http://www.microsoft.com/express/vc/" onclick="javascript:pageTracker._trackPageview('/external/www.microsoft.com/express/vc/');" >Visual C++ 2008 Express Edition</a> or any retail version of VS 2008 if you want to build your own mod_python for 2.6 (I&#8217;ll provide a precompiled one in this post).</p>
<h2>Preparing</h2>
<p>Install Python 2.6 and 
<a  href="http://trac.edgewall.org/wiki/TracInstall" onclick="javascript:pageTracker._trackPageview('/external/trac.edgewall.org/wiki/TracInstall');" >Trac on 2.6</a> (using &#8220;
<a  href="http://peak.telecommunity.com/DevCenter/EasyInstall#installing-easy-install" onclick="javascript:pageTracker._trackPageview('/external/peak.telecommunity.com/DevCenter/EasyInstall?installing-easy-install');" >easy_install</a> trac&#8221; is recommended)</p>
<p>You&#8217;ll probably also want to easy_install 
<a  href="http://pygments.org/" onclick="javascript:pageTracker._trackPageview('/external/pygments.org/');" >Pygments</a> for source highlighting.</p>
<h2>Building mod_python for 2.6</h2>
<p>This 
<a  href="http://badwords.org/w/Compile_mod_python_for_Python_2.6.1" onclick="javascript:pageTracker._trackPageview('/external/badwords.org/w/Compile_mod_python_for_Python_2.6.1');" >guide to mod_python</a> covers the creation and installation of a compatible version of the module.</p>
<p>At this point, you should be able to restart Apache and load up your &#8220;old&#8221; Trac on Python 2.6, but with the error message that &#8220;svn&#8221; support is not installed.</p>
<p>A pre-built version of this can be found here: 
<a  href="http://vagabonds.info/python/mod_python-3.3.2-dev-20080819.win32-py2.6.exe" onclick="javascript:pageTracker._trackPageview('/external/vagabonds.info/python/mod_python-3.3.2-dev-20080819.win32-py2.6.exe');" >mod_python-3.3.2-dev-20080819.win32-py2.6.exe</a></p>
<h2>Python SVN bindings</h2>
<p>My 
<a  href="http://www.lejordet.com/2009/03/making-a-trac-install-work-on-apache-22python-26win32/">old guide</a> had instructions on how to build these yourself, but after that article was made, 
<a  href="http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=8100" onclick="javascript:pageTracker._trackPageview('/external/subversion.tigris.org/servlets/ProjectDocumentList');" >&#8220;official&#8221; Python 2.6 bindings</a> have been released.</p>
<p>Most recent version as of this writing is the 
<a  href="http://subversion.tigris.org/files/documents/15/46888/svn-python-1.6.6.win32-py2.6.exe" onclick="javascript:pageTracker._trackPageview('/external/subversion.tigris.org/files/documents/15/46888/svn-python-1.6.6.win32-py2.6.exe');" >SVN 1.6.6 version of the bindings</a>.</p>
<h2>Replacing Apache DLLs to make libsvn work</h2>
<p><em>Note: Only use these instructions if you experience problems, and/or you&#8217;re running a self-built version of the Python SVN bindings already.</em></p>
<p>There&#8217;s a slight difference between libapr-1.dll as supplied with Apache 2.2 and the one we built together with libsvn, so 
<a  href="http://trac.edgewall.org/ticket/6739#comment:9" onclick="javascript:pageTracker._trackPageview('/external/trac.edgewall.org/ticket/6739?comment:9');" >the fix</a> is to replace the one in your Apache2.2\bin folder with the one from your Python2.6\Lib\site-packages\libsvn folder (copy the libsvn_*.dlls from the same folder into the Apache2.2\bin folder if you still get problems).</p>
<p>Restarting Apache now should make Trac work fully, with Subversion support.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lejordet.com/2010/01/making-a-trac-install-work-on-apache-2-2python-2-6win32-2010-edition/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>lxml for Python 2.6/win32</title>
		<link>http://www.lejordet.com/2009/12/lxml-for-python26-win32/</link>
		<comments>http://www.lejordet.com/2009/12/lxml-for-python26-win32/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 12:03:35 +0000</pubDate>
		<dc:creator>Lars Erik Jordet</dc:creator>
				<category><![CDATA[packages]]></category>
		<category><![CDATA[compile]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[python2.6]]></category>
		<category><![CDATA[win32]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.lejordet.com/?p=95</guid>
		<description><![CDATA[A pre-built statically linked lxml 2.2.4 for Windows/Python 2.6]]></description>
			<content:encoded><![CDATA[<p>A quick post today: Using 
<a  href="http://codespeak.net/lxml/build.html" onclick="javascript:pageTracker._trackPageview('/external/codespeak.net/lxml/build.html');" >these instructions</a>, I&#8217;ve built a statically linked lxml 2.2.4 for Windows.</p>
<p>I used the following versions of the libraries:</p>
<div class="codecolorer-container python blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">STATIC_INCLUDE_DIRS = <span style="color: black;">&#91;</span><br />
<span style="color: #483d8b;">&quot;..<span style="color: #000099; font-weight: bold;">\\</span>libxml2-2.7.6.win32<span style="color: #000099; font-weight: bold;">\\</span>include&quot;</span>,<br />
<span style="color: #483d8b;">&quot;..<span style="color: #000099; font-weight: bold;">\\</span>libxslt-1.1.26.win32<span style="color: #000099; font-weight: bold;">\\</span>include&quot;</span>,<br />
<span style="color: #483d8b;">&quot;..<span style="color: #000099; font-weight: bold;">\\</span>zlib-1.2.3.win32<span style="color: #000099; font-weight: bold;">\\</span>include&quot;</span>,<br />
<span style="color: #483d8b;">&quot;..<span style="color: #000099; font-weight: bold;">\\</span>iconv-1.9.2.win32<span style="color: #000099; font-weight: bold;">\\</span>include&quot;</span><br />
<span style="color: black;">&#93;</span></div></td></tr></tbody></table></div>
<div class="codecolorer-container python blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">STATIC_LIBRARY_DIRS = <span style="color: black;">&#91;</span><br />
<span style="color: #483d8b;">&quot;..<span style="color: #000099; font-weight: bold;">\\</span>libxml2-2.7.6.win32<span style="color: #000099; font-weight: bold;">\\</span>lib&quot;</span>,<br />
<span style="color: #483d8b;">&quot;..<span style="color: #000099; font-weight: bold;">\\</span>libxslt-1.1.26.win32<span style="color: #000099; font-weight: bold;">\\</span>lib&quot;</span>,<br />
<span style="color: #483d8b;">&quot;..<span style="color: #000099; font-weight: bold;">\\</span>zlib-1.2.3.win32<span style="color: #000099; font-weight: bold;">\\</span>lib&quot;</span>,<br />
<span style="color: #483d8b;">&quot;..<span style="color: #000099; font-weight: bold;">\\</span>iconv-1.9.2.win32<span style="color: #000099; font-weight: bold;">\\</span>lib&quot;</span><br />
<span style="color: black;">&#93;</span></div></td></tr></tbody></table></div>
<p>Download it here: 
<a  href="/files/python/lxml-2.2.4.win32-py2.6.exe" onclick="javascript:pageTracker._trackPageview('/downloads/files/python/lxml-2.2.4.win32-py2.6.exe');" >lxml-2.2.4.win32-py2.6</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lejordet.com/2009/12/lxml-for-python26-win32/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Embedding Google Wave in WordPress</title>
		<link>http://www.lejordet.com/2009/11/embedding-google-wave-in-wordpress/</link>
		<comments>http://www.lejordet.com/2009/11/embedding-google-wave-in-wordpress/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 12:27:04 +0000</pubDate>
		<dc:creator>Lars Erik Jordet</dc:creator>
				<category><![CDATA[wave]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[meta]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.lejordet.com/?p=87</guid>
		<description><![CDATA[A simple test of adding a Google Wave in WordPress]]></description>
			<content:encoded><![CDATA[<p>This is an attempt to embed a 
<a  href="http://wave.google.com" onclick="javascript:pageTracker._trackPageview('/external/wave.google.com');" >Google Wave</a> &#8230;eh&#8230; Wave in a WordPress post.</p>
<p>For this I use the beta version of the 
<a  href="http://wordpress.org/extend/plugins/wavr/" onclick="javascript:pageTracker._trackPageview('/external/wordpress.org/extend/plugins/wavr/');" >Wavr</a> plugin, and a test wave I made:</p>

		<div id="waveframe-1"  style="width:100%;height:500px;"  ></div>
		 <script type="text/javascript">

				add_wave("waveframe-1",{
					bgcolor:"#ffffff",
					color:"#000000",
					font:"Verdana, Arial, Helvetica, sans-serif",
					font_size:"1em",
					width:"100%",
					height:"500px",
					server:"https://wave.google.com/wave/",
					id:"googlewave.com!w+7Mw4xNkZA"		});

		</script>
		
<p>The code to add the above wave is:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">[wave id=&quot;googlewave.com!w+7Mw4xNkZA&quot; color=&quot;#000000&quot; bgcolor=&quot;#ffffff&quot; font=&quot;Verdana, Arial, Helvetica, sans-serif&quot;]</div></td></tr></tbody></table></div>
<p>In this testwave I added the bot &#8220;easypublic@appspot.com&#8221;, which makes the wave public for you (I couldn&#8217;t get the &#8220;official&#8221; way of adding public@a.gwave.com to work).</p>
<p>You&#8217;ll need a Wave account to see the above; if you don&#8217;t, I currently have 2 invites to spare, just comment below.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lejordet.com/2009/11/embedding-google-wave-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>deadbeef random number generator in F#</title>
		<link>http://www.lejordet.com/2009/11/deadbeef-random-number-generator-in-fsharp/</link>
		<comments>http://www.lejordet.com/2009/11/deadbeef-random-number-generator-in-fsharp/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 15:53:24 +0000</pubDate>
		<dc:creator>Lars Erik Jordet</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[fsharp]]></category>
		<category><![CDATA[random]]></category>
		<category><![CDATA[source]]></category>

		<guid isPermaLink="false">http://www.lejordet.com/?p=80</guid>
		<description><![CDATA[A quick implementation of the <a href="http://inglorion.net/software/deadbeef_rand/">Deadbeef Random Number Generator</a> in F#.]]></description>
			<content:encoded><![CDATA[<p>I found the 
<a  href="http://inglorion.net/software/deadbeef_rand/" onclick="javascript:pageTracker._trackPageview('/external/inglorion.net/software/deadbeef_rand/');" >Deadbeef Random Number Generator</a> when reading the 
<a  href="http://www.reddit.com/r/programming/comments/a4j4a/whats_the_best_most_interesting_piece_of_code/" onclick="javascript:pageTracker._trackPageview('/external/www.reddit.com/r/programming/comments/a4j4a/whats_the_best_most_interesting_piece_of_code/');" >Reddit thread &#8220;What&#8217;s the best / most interesting piece of code you&#8217;ve ever seen?&#8221;</a> &#8211; and since I&#8217;m trying to learn 
<a  href="http://fsharp.net" onclick="javascript:pageTracker._trackPageview('/external/fsharp.net');" >F#</a>, I figured I could try implementing it, first in an &#8220;imperative&#8221; way, then in a more functional way.</p>
<p>First the imperative way, a kind of naïve translation of the C code presented:</p>
<div class="codecolorer-container fsharp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="fsharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #06c; font-weight: bold;">let</span> <span style="color: #06c; font-weight: bold;">mutable</span> <span style="color: #6c6;">&#40;</span>deadbeef_seed:<span style="color: #06c; font-weight: bold;">uint32</span><span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">=</span> <span style="color: #06c; font-weight: bold;">uint32</span> <span style="color: #c6c;">0</span><span style="color: #a52a2a;">;</span><br />
<span style="color: #06c; font-weight: bold;">let</span> <span style="color: #06c; font-weight: bold;">mutable</span> <span style="color: #6c6;">&#40;</span>deadbeef_beef:<span style="color: #06c; font-weight: bold;">uint32</span><span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">=</span> <span style="color: #06c; font-weight: bold;">uint32</span> 0xdeadbeef<span style="color: #a52a2a;">;</span><br />
<br />
<span style="color: #06c; font-weight: bold;">let</span> deadbeef_srand x <span style="color: #a52a2a;">=</span><br />
&nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">let</span> oldseed <span style="color: #a52a2a;">=</span> deadbeef_seed<br />
&nbsp; &nbsp; deadbeef_seed <span style="color: #a52a2a;">&lt;-</span> x<br />
&nbsp; &nbsp; deadbeef_beef <span style="color: #a52a2a;">&lt;-</span> <span style="color: #06c; font-weight: bold;">uint32</span> 0xdeadbeef<br />
&nbsp; &nbsp; oldseed<br />
<br />
<span style="color: #06c; font-weight: bold;">let</span> deadbeef_rand <span style="color: #6c6;">&#40;</span><span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">=</span><br />
&nbsp; &nbsp; deadbeef_seed <span style="color: #a52a2a;">&lt;-</span> <span style="color: #6c6;">&#40;</span>deadbeef_seed <span style="color: #a52a2a;">&lt;&lt;&lt;</span> <span style="color: #c6c;">7</span><span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">^^^</span> <span style="color: #6c6;">&#40;</span><span style="color: #6c6;">&#40;</span>deadbeef_seed <span style="color: #a52a2a;">&gt;&gt;&gt;</span> <span style="color: #c6c;">25</span><span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">+</span> deadbeef_beef<span style="color: #6c6;">&#41;</span><span style="color: #a52a2a;">;</span><br />
&nbsp; &nbsp; deadbeef_beef <span style="color: #a52a2a;">&lt;-</span> <span style="color: #6c6;">&#40;</span>deadbeef_beef <span style="color: #a52a2a;">&lt;&lt;&lt;</span> <span style="color: #c6c;">7</span><span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">^^^</span> <span style="color: #6c6;">&#40;</span><span style="color: #6c6;">&#40;</span>deadbeef_beef <span style="color: #a52a2a;">&gt;&gt;&gt;</span> <span style="color: #c6c;">25</span><span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">+</span> <span style="color: #6c6;">&#40;</span><span style="color: #06c; font-weight: bold;">uint32</span> 0xdeadbeef<span style="color: #6c6;">&#41;</span><span style="color: #6c6;">&#41;</span><span style="color: #a52a2a;">;</span><br />
&nbsp; &nbsp; deadbeef_seed<span style="color: #a52a2a;">;</span></div></td></tr></tbody></table></div>
<p>This is not very <em>functional</em>, with mutables and all that, so I tried again, with an implementation requiring no mutable variables:</p>
<div class="codecolorer-container fsharp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="fsharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #06c; font-weight: bold;">let</span> deadbeef_rand_seq seed <span style="color: #a52a2a;">=</span> <span style="color: #06c; font-weight: bold;">seq</span> <span style="color: #6c6;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">let</span> <span style="color: #06c; font-weight: bold;">rec</span> db_rand seed beef <span style="color: #a52a2a;">=</span> <span style="color: #06c; font-weight: bold;">seq</span> <span style="color: #6c6;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">let</span> newseed <span style="color: #a52a2a;">=</span> <span style="color: #6c6;">&#40;</span>seed <span style="color: #a52a2a;">&lt;&lt;&lt;</span> <span style="color: #c6c;">7</span><span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">^^^</span> <span style="color: #6c6;">&#40;</span><span style="color: #6c6;">&#40;</span>seed <span style="color: #a52a2a;">&gt;&gt;&gt;</span> <span style="color: #c6c;">25</span><span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">+</span> beef<span style="color: #6c6;">&#41;</span><span style="color: #a52a2a;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">let</span> newbeef <span style="color: #a52a2a;">=</span> <span style="color: #6c6;">&#40;</span>beef <span style="color: #a52a2a;">&lt;&lt;&lt;</span> <span style="color: #c6c;">7</span><span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">^^^</span> <span style="color: #6c6;">&#40;</span><span style="color: #6c6;">&#40;</span>beef <span style="color: #a52a2a;">&gt;&gt;&gt;</span> <span style="color: #c6c;">25</span><span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">+</span> <span style="color: #6c6;">&#40;</span><span style="color: #06c; font-weight: bold;">uint32</span> 0xdeadbeef<span style="color: #6c6;">&#41;</span><span style="color: #6c6;">&#41;</span><span style="color: #a52a2a;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">yield</span> newseed<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">yield!</span> db_rand newseed newbeef<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6c6;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">yield!</span> db_rand seed <span style="color: #6c6;">&#40;</span><span style="color: #06c; font-weight: bold;">uint32</span> 0xdeadbeef<span style="color: #6c6;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #6c6;">&#125;</span></div></td></tr></tbody></table></div>
<p>&#8230;much better (at least in my opinion); implemented as a sequence of random numbers, <tt>deadbeef_rand_seq(seed).Take(10)</tt> would give you 10 random <tt>uint32</tt>s.<br />
I&#8217;ll bet there are about 1000 other ways to make this more F#-like/more functional, so I&#8217;d love to hear about them!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lejordet.com/2009/11/deadbeef-random-number-generator-in-fsharp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Moving to new domain</title>
		<link>http://www.lejordet.com/2009/08/moving-to-new-domain/</link>
		<comments>http://www.lejordet.com/2009/08/moving-to-new-domain/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 11:48:04 +0000</pubDate>
		<dc:creator>Lars Erik Jordet</dc:creator>
				<category><![CDATA[SFLR]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[meta]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.lejordet.com/2009/08/moving-to-new-domain/</guid>
		<description><![CDATA[SFLR was moved to a new domain, and a few of the pitfalls on the way are described.]]></description>
			<content:encoded><![CDATA[<p>SFLR moved WordPress from vagabonds.info/wp to lejordet.com.</p>
<p>In spirit of the site, here are some of the pitfalls of moving WordPress:</p>
<h2>Getting search engines to redirect correctly</h2>
<p>I set up the old site to return 
<a  href="http://en.wikipedia.org/wiki/HTTP_301" onclick="javascript:pageTracker._trackPageview('/external/en.wikipedia.org/wiki/HTTP_301');" >HTTP 301 &#8211; Moved Permanently</a> by putting the following .htaccess file in the /wp folder:</p>
<div class="codecolorer-container apache blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="apache codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #00007f;">RewriteEngine</span> <span style="color: #0000ff;">on</span><br />
<br />
<span style="color: #00007f;">RewriteCond</span> %{HTTP_HOST} ^([^.:]+\.)*vagabonds\.info\.?(:[<span style="color: #ff0000;">0</span>-<span style="color: #ff0000;">9</span>]*)?$ [NC]<br />
<span style="color: #00007f;">RewriteRule</span> ^(.*)$ http://www.lejordet.com/$<span style="color: #ff0000;">1</span> [R=<span style="color: #ff0000;">301</span>,L]</div></td></tr></tbody></table></div>
<p>This ensures that (most) search engines consider the new location as equivalent to the previous, and will &#8211; hopefully &#8211; make only the new location appear in search results.</p>
<h2>All my WordPress pages are blank after the move!</h2>
<p>Assuming you&#8217;ve followed the 
<a  href="http://codex.wordpress.org/Moving_WordPress" onclick="javascript:pageTracker._trackPageview('/external/codex.wordpress.org/Moving_WordPress');" >standard operating procedure</a> for moving the blog, and all 
<a  href="http://www.mydigitallife.info/2007/10/01/how-to-move-wordpress-blog-to-new-domain-or-location/" onclick="javascript:pageTracker._trackPageview('/external/www.mydigitallife.info/2007/10/01/how-to-move-wordpress-blog-to-new-domain-or-location/');" >database entries are updated</a> to the new path (I did this part manually, but the linked procedure seems OK), the most likely reason is that your plugins are still using the old path. If you can still re-enable the old path (in my case, I moved /wp to /wp-deactivated), go in to the admin panel and deactivate all plugins.</p>
<p>They can also be 
<a  href="http://www.bestwpthemez.com/wordpress/how-to-disable-all-wordpress-plugins-from-the-database-2205/" onclick="javascript:pageTracker._trackPageview('/external/www.bestwpthemez.com/wordpress/how-to-disable-all-wordpress-plugins-from-the-database-2205/');" >deactivated from the database</a>, if you have no way of returning to the old installation:</p>
<div class="codecolorer-container sql blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="sql codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #993333; font-weight: bold;">UPDATE</span> wp_options <span style="color: #993333; font-weight: bold;">SET</span> option_value <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">''</span> <span style="color: #993333; font-weight: bold;">WHERE</span> option_name <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'active_plugins'</span>;</div></td></tr></tbody></table></div>
<p>When everything works again you can reactivate the plugins, and things should be back to normal.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lejordet.com/2009/08/moving-to-new-domain/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Printing to PDF from VBA in Excel</title>
		<link>http://www.lejordet.com/2009/07/printing-to-pdf-from-vba-in-excel/</link>
		<comments>http://www.lejordet.com/2009/07/printing-to-pdf-from-vba-in-excel/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 12:50:35 +0000</pubDate>
		<dc:creator>Lars Erik Jordet</dc:creator>
				<category><![CDATA[office]]></category>
		<category><![CDATA[acrobat]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[vba]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.lejordet.com/?p=43</guid>
		<description><![CDATA[Fully automated PDF production from Excel, using VBA]]></description>
			<content:encoded><![CDATA[<p>Creating a PDF from Excel typically requires printing to the &#8220;Adobe PDF&#8221; printer, selecting the location and file name to save the .pdf as, and finally getting the newly created PDF opened in Acrobat. Automating this is not very straight-forward, and took quite a while to get &#8220;right&#8221;.</p>
<h2>Background</h2>
<p>There is no direct COM API that can be used to tell Acrobat to &#8220;convert this sheet to PDF please&#8221;, and all the solutions I&#8217;ve found on the net have been missing pieces of the puzzle (i.e. lots of hardcoded values, only works on the computer they were made on, or requires you to do manual steps before you can start.)</p>
<p>The most common manual step is that you have to uncheck &#8220;Don&#8217;t send fonts to Adobe PDF&#8221;, or as it&#8217;s called in recent versions of Acrobat:</p>
<div id="attachment_44" class="wp-caption alignnone" style="width: 533px"><img class="size-full wp-image-44" title="Adobe PDF fonts" src="http://www.lejordet.com/wp-content/uploads/2009/07/pdf_fonts.jpg" alt="Adobe PDF setting: Use system fonts" width="523" height="431" /><p class="wp-caption-text">Adobe PDF setting: Use system fonts</p></div>
<p>The problem here is that this setting is in no way persistent, often resetting to its checked state &#8211; and there is no registry setting or .ini file setting to force it unchecked.</p>
<h2>What you&#8217;ll need</h2>
<p>As usual, these are the specific versions I use &#8211; other versions should work just as well.</p>
<ul>
<li>Excel 2003</li>
<li>Adobe Acrobat 8</li>
<li>A printer with a PostScript driver (you can also install a dummy printer if you don&#8217;t have a &#8220;real&#8221; printer)</li>
</ul>
<h2>The code</h2>
<p>Some of this code is based on 
<a  href="http://www.pcreview.co.uk/forums/thread-2854620.php" target="_blank" onclick="javascript:pageTracker._trackPageview('/external/www.pcreview.co.uk/forums/thread-2854620.php');" >this PCreview.co.uk forums post</a> (I can&#8217;t remember if this was my original source, but it&#8217;s the closest I can find)</p>
<p>You&#8217;ll need the file 
<a title="cAcroDist.cls"  href="http://vagabonds.info/vba/cAcroDist.cls" onclick="javascript:pageTracker._trackPageview('/external/vagabonds.info/vba/cAcroDist.cls');" >cAcroDist.cls</a>, a class that handles the Distiller events &#8211; either import the linked file, or create a new class in VBA and paste the following:</p>
<div class="codecolorer-container vb blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br /></div></td><td><div class="vb codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000080;">Option</span> <span style="color: #000080;">Explicit</span><br />
<br />
<span style="color: #000080;">Public</span> <span style="color: #000080;">WithEvents</span> odist <span style="color: #000080;">As</span> PdfDistiller<br />
Attribute odist.VB_VarHelpID = -1<br />
<span style="color: #000080;">Dim</span> StartTime <span style="color: #000080;">As</span> <span style="color: #000080;">Date</span><br />
<br />
<span style="color: #000080;">Private</span> <span style="color: #000080;">Sub</span> Class_Initialize()<br />
&nbsp;<span style="color: #000080;">Set</span> odist = <span style="color: #000080;">New</span> PdfDistiller<br />
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span><br />
<br />
<span style="color: #000080;">Private</span> <span style="color: #000080;">Sub</span> odist_OnJobDone(<span style="color: #000080;">ByVal</span> strInputPostScript <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>, <span style="color: #000080;">ByVal</span> strOutputPDF <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>)<br />
&nbsp;Kill strInputPostScript <span style="color: #008000;">' deletes the input postscript, since it's not needed after PDF is made<br />
</span><span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span><br />
<br />
<span style="color: #000080;">Private</span> <span style="color: #000080;">Sub</span> odist_OnJobFail(<span style="color: #000080;">ByVal</span> strInputPostScript <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>, <span style="color: #000080;">ByVal</span> strOutputPDF <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>)<br />
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span><br />
<br />
<span style="color: #000080;">Private</span> <span style="color: #000080;">Sub</span> odist_OnJobStart(<span style="color: #000080;">ByVal</span> strInputPostScript <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>, <span style="color: #000080;">ByVal</span> strOutputPDF <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>)<br />
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span></div></td></tr></tbody></table></div>
<p>On to the PDF producing code &#8211; either use the code below, or import this handy pre-made module: 
<a title="PrintToPDF.bas"  href="http://vagabonds.info/vba/PrintToPDF.bas" onclick="javascript:pageTracker._trackPageview('/external/vagabonds.info/vba/PrintToPDF.bas');" >PrintToPDF.bas</a> (note that this needs some manual changes).</p>
<p>In a new module, create the following Sub:</p>
<div class="codecolorer-container vb blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br /></div></td><td><div class="vb codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000080;">Sub</span> PrintToPDF(sPDFFileName, SheetName)<br />
<br />
&nbsp;<span style="color: #000080;">Dim</span> sPSFileName <span style="color: #000080;">As</span> <span style="color: #000080;">String</span> <span style="color: #008000;">'Name of PS to be created<br />
</span> <span style="color: #000080;">Dim</span> sJobOptions <span style="color: #000080;">As</span> <span style="color: #000080;">String</span><br />
&nbsp;<span style="color: #000080;">Dim</span> sCurrentPrinter <span style="color: #000080;">As</span> <span style="color: #000080;">String</span> <span style="color: #008000;">'Same current printer choice to resume at end<br />
</span> <span style="color: #000080;">Dim</span> sPDFVersionAndPort <span style="color: #000080;">As</span> <span style="color: #000080;">String</span> <span style="color: #008000;">'Version of Adobe<br />
</span> <span style="color: #000080;">Dim</span> sDummyPrinter <span style="color: #000080;">As</span> <span style="color: #000080;">String</span> <span style="color: #008000;">' Need a dummy printer to produce the PS<br />
</span> <span style="color: #000080;">Dim</span> appDist <span style="color: #000080;">As</span> cAcroDist<br />
<br />
&nbsp;<span style="color: #000080;">Set</span> appDist = <span style="color: #000080;">New</span> cAcroDist<br />
&nbsp;sCurrentPrinter = Application.ActivePrinter <span style="color: #008000;">'Save the currently active printer<br />
</span> sDummyPrinter = NetworkPrinter(<span style="color: #800000;">&quot;Dummy Printer Name&quot;</span>) <span style="color: #008000;">' Change this to match an installed PS-capable printer driver<br />
</span> Application.ActivePrinter = sDummyPrinter<br />
&nbsp;sPSFileName = ThisWorkbook.Path &amp; ThisWorkbook.Name &amp; <span style="color: #800000;">&quot;.ps&quot;</span>  <span style="color: #008000;">'Name of PS file<br />
</span> ThisWorkbook.Sheets(SheetName).PrintOut ActivePrinter:=sDummyPrinter, _<br />
&nbsp;PrintToFile:=<span style="color: #000080;">True</span>, PrToFileName:=sPSFileName <span style="color: #008000;">'Prints to PS<br />
</span><br />
&nbsp;<span style="color: #000080;">Call</span> appDist.odist.FileToPDF(sPSFileName, sPDFFileName, sJobOptions) <span style="color: #008000;">'Creates PDF<br />
</span><br />
&nbsp;<span style="color: #000080;">On</span> <span style="color: #000080;">Error</span> <span style="color: #000080;">Resume</span> <span style="color: #000080;">Next</span><br />
&nbsp;Kill sPSFileName <span style="color: #008000;">'Removes PS<br />
</span> <span style="color: #000080;">On</span> <span style="color: #000080;">Error</span> <span style="color: #000080;">GoTo</span> 0<br />
<br />
&nbsp;Application.ActivePrinter = sCurrentPrinter <span style="color: #008000;">'Change back to the original printer<br />
</span><span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span></div></td></tr></tbody></table></div>
<p>This procedure finds a specifically named printer, uses its driver to produce a PostScript file, then uses Acrobat Distiller to convert the .ps to .pdf. You will need to add a reference to <strong>Acrobat Distiller</strong> manually in the VBA editor.</p>
<p>Finally, we need the NetworkPrinter function, which locates which port a printer is on &#8211; you CAN hardcode sDummyPrinter to something like &#8220;HP Deskjet on Ne03:&#8221;, but that will only work on computers that have the printer on that exact port. The 
<a  href="http://www.tek-tips.com/viewthread.cfm?qid=879030" onclick="javascript:pageTracker._trackPageview('/external/www.tek-tips.com/viewthread.cfm');" >NetworkPrinter function</a> &#8211; slightly modified solves this:</p>
<div class="codecolorer-container vb blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br /></div></td><td><div class="vb codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000080;">Dim</span> Prt_On <span style="color: #000080;">As</span> <span style="color: #000080;">String</span><br />
<br />
<span style="color: #000080;">Function</span> NetworkPrinter(<span style="color: #000080;">ByVal</span> myprinter <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>)<br />
&nbsp;<span style="color: #000080;">On</span> <span style="color: #000080;">Error</span> <span style="color: #000080;">Resume</span> <span style="color: #000080;">Next</span><br />
<br />
&nbsp;<span style="color: #000080;">Dim</span> NetWork <span style="color: #000080;">As</span> <span style="color: #000080;">Variant</span><br />
&nbsp;<span style="color: #000080;">Dim</span> X <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span><br />
&nbsp;Prt_On = <span style="color: #800000;">&quot; On &quot;</span><br />
<span style="color: #008000;">'/// Define NetWork Array \\\<br />
</span> NetWork = Array(<span style="color: #800000;">&quot;Ne00:&quot;</span>, <span style="color: #800000;">&quot;Ne01:&quot;</span>, <span style="color: #800000;">&quot;Ne02:&quot;</span>, <span style="color: #800000;">&quot;Ne03:&quot;</span>, <span style="color: #800000;">&quot;Ne04:&quot;</span>, _<br />
&nbsp;<span style="color: #800000;">&quot;Ne05:&quot;</span>, <span style="color: #800000;">&quot;Ne06:&quot;</span>, <span style="color: #800000;">&quot;Ne07:&quot;</span>, <span style="color: #800000;">&quot;Ne08:&quot;</span>, _<br />
&nbsp;<span style="color: #800000;">&quot;Ne09:&quot;</span>, <span style="color: #800000;">&quot;Ne10:&quot;</span>, <span style="color: #800000;">&quot;Ne11:&quot;</span>, <span style="color: #800000;">&quot;Ne12:&quot;</span>, _<br />
&nbsp;<span style="color: #800000;">&quot;Ne13:&quot;</span>, <span style="color: #800000;">&quot;Ne14:&quot;</span>, <span style="color: #800000;">&quot;Ne15:&quot;</span>, <span style="color: #800000;">&quot;Ne16:&quot;</span>, _<br />
&nbsp;<span style="color: #800000;">&quot;LPT1:&quot;</span>, <span style="color: #800000;">&quot;LPT2:&quot;</span>, <span style="color: #800000;">&quot;File:&quot;</span>, <span style="color: #800000;">&quot;SMC100:&quot;</span>, _<br />
&nbsp;<span style="color: #800000;">&quot;XPSPort:&quot;</span>)<br />
&nbsp;<span style="color: #008000;">'Setup printer to Print<br />
</span> X = 0<br />
TryAgain:<br />
&nbsp;<span style="color: #000080;">On</span> <span style="color: #000080;">Error</span> <span style="color: #000080;">Resume</span> <span style="color: #000080;">Next</span><br />
&nbsp;<span style="color: #008000;">'Printer<br />
</span> Application.ActivePrinter = myprinter &amp; Prt_On &amp; NetWork(X)<br />
&nbsp; <span style="color: #000080;">If</span> Err.Number &lt;&gt; 0 <span style="color: #000080;">And</span> X &lt; <span style="color: #000080;">UBound</span>(NetWork) <span style="color: #000080;">Then</span><br />
&nbsp; &nbsp; X = X + 1<br />
&nbsp; &nbsp; <span style="color: #000080;">GoTo</span> TryAgain<br />
&nbsp; <span style="color: #000080;">ElseIf</span> Err.Number &lt;&gt; 0 <span style="color: #000080;">And</span> X &gt; <span style="color: #000080;">UBound</span>(NetWork) - 1 <span style="color: #000080;">Then</span><br />
&nbsp;<span style="color: #000080;">GoTo</span> PrtError<br />
&nbsp;<span style="color: #000080;">End</span> <span style="color: #000080;">If</span><br />
&nbsp;<span style="color: #000080;">On</span> <span style="color: #000080;">Error</span> <span style="color: #000080;">GoTo</span> 0<br />
&nbsp;NetworkPrinter = myprinter &amp; Prt_On &amp; NetWork(X)<br />
errorExit:<br />
&nbsp;<span style="color: #000080;">Exit</span> <span style="color: #000080;">Function</span><br />
PrtError:<br />
&nbsp;<span style="color: #008000;">'no printer found<br />
</span> NetworkPrinter = <span style="color: #800000;">&quot;&quot;</span><br />
&nbsp;<span style="color: #000080;">Resume</span> errorExit<br />
<span style="color: #000080;">End</span> <span style="color: #000080;">Function</span></div></td></tr></tbody></table></div>
<p>This is also defined in PrintToPDF.bas linked above.</p>
<h2>Example use</h2>
<p>To convert the &#8220;Report&#8221; sheet in the currently active workbook to a PDF, use this code:</p>
<div class="codecolorer-container vb blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="vb codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">PrintToPDF <span style="color: #800000;">&quot;C:\MyReport.pdf&quot;</span>, <span style="color: #800000;">&quot;Report&quot;</span></div></td></tr></tbody></table></div>
<p><span id="more-43"></span></p>
<h2>Troubleshooting</h2>
<h3>No PDF produced</h3>
<p>If the printer you use for conversion doesn&#8217;t support PostScript, you&#8217;ll only end up with a text file called MyReport.txt (following the example above) containing an error message. Change to a different printer to avoid this &#8211; alternatively install a fake printer (see next section) to get a compatible driver.</p>
<h3>PDF produced has paper size &#8220;letter&#8221;, regardless of settings</h3>
<p>I&#8217;m still working on fixing that one&#8230;</p>
<h2>Installing a fake printer</h2>
<p>From Start -&gt; Printers and Faxes -&gt; Add a printer</p>
<div id="attachment_45" class="wp-caption alignnone" style="width: 513px"><img class="size-full wp-image-45" title="Installing a fake printer, step 1/6" src="http://www.lejordet.com/wp-content/uploads/2009/07/fakeprinter_1.jpg" alt="Installing a fake printer, step 1/6" width="503" height="385" /><p class="wp-caption-text">Installing a fake printer, step 1/6</p></div>
<div id="attachment_46" class="wp-caption alignnone" style="width: 513px"><img class="size-full wp-image-46" title="Installing a fake printer, step 2/6" src="http://www.lejordet.com/wp-content/uploads/2009/07/fakeprinter_2.jpg" alt="Installing a fake printer, step 2/6" width="503" height="385" /><p class="wp-caption-text">Installing a fake printer, step 2/6</p></div>
<div id="attachment_47" class="wp-caption alignnone" style="width: 513px"><img class="size-full wp-image-47" title="Installing a fake printer, step 3/6" src="http://www.lejordet.com/wp-content/uploads/2009/07/fakeprinter_3.jpg" alt="Installing a fake printer, step 3/6" width="503" height="385" /><p class="wp-caption-text">Installing a fake printer, step 3/6</p></div>
<div id="attachment_48" class="wp-caption alignnone" style="width: 513px"><img class="size-full wp-image-48" title="Installing a fake printer, step 4/6" src="http://www.lejordet.com/wp-content/uploads/2009/07/fakeprinter_4.jpg" alt="Installing a fake printer, step 4/6" width="503" height="385" /><p class="wp-caption-text">Installing a fake printer, step 4/6</p></div>
<div id="attachment_49" class="wp-caption alignnone" style="width: 513px"><img class="size-full wp-image-49" title="Installing a fake printer, step 5/6" src="http://www.lejordet.com/wp-content/uploads/2009/07/fakeprinter_5.jpg" alt="Installing a fake printer, step 5/6" width="503" height="385" /><p class="wp-caption-text">Installing a fake printer, step 5/6</p></div>
<div id="attachment_50" class="wp-caption alignnone" style="width: 513px"><img class="size-full wp-image-50" title="Installing a fake printer, step 6/6" src="http://www.lejordet.com/wp-content/uploads/2009/07/fakeprinter_6.jpg" alt="Installing a fake printer, step 6/6" width="503" height="385" /><p class="wp-caption-text">Installing a fake printer, step 6/6</p></div>
<p>In short, add a new local  printer on LPT1: &#8211; don&#8217;t search for PnP printers &#8211; using a random printer driver with PS in the name (I used the <em>HP Color LaserJet PS</em> &#8211; I&#8217;m not sure if a non-color printer would work, too), and don&#8217;t print a test page. It would probably be possible to share this printer with a network and have everyone install it to have a unified way of printing on a set of computers, but I haven&#8217;t tested this.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lejordet.com/2009/07/printing-to-pdf-from-vba-in-excel/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->