<?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; windows</title>
	<atom:link href="http://www.lejordet.com/category/windows/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>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>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>
		<item>
		<title>Fixing a RAID1 that suddenly becomes write protected (64 bit Windows)</title>
		<link>http://www.lejordet.com/2009/05/raid1-write-protected-64bit-windows/</link>
		<comments>http://www.lejordet.com/2009/05/raid1-write-protected-64bit-windows/#comments</comments>
		<pubDate>Thu, 14 May 2009 17:34:34 +0000</pubDate>
		<dc:creator>Lars Erik Jordet</dc:creator>
				<category><![CDATA[windows]]></category>
		<category><![CDATA[64bit]]></category>
		<category><![CDATA[diskpart]]></category>
		<category><![CDATA[driver]]></category>
		<category><![CDATA[raid]]></category>

		<guid isPermaLink="false">http://www.lejordet.com/?p=33</guid>
		<description><![CDATA[How to fix a write protected RAID in 64 bit Windows]]></description>
			<content:encoded><![CDATA[<p>Today, after rebooting from some Windows updates, my RAID1 disk suddenly was write protected &#8211; but a way to change it was nowhere to be found. After some digging, I found that 
<a title="partition write protected"  href="http://www.vistaheads.com/forums/microsoft-public-windows-vista-general/114730-partion-write-protected.html" onclick="javascript:pageTracker._trackPageview('/external/www.vistaheads.com/forums/microsoft-public-windows-vista-general/114730-partion-write-protected.html');" >others have reported the same problem</a>.</p>
<h2>Background</h2>
<p>As far as I can tell, it seems to be a weakness in the 64-bit drivers for the on-board RAID on some motherboards that causes it. For the record, mine is a Gigabyte 
<a  href="http://www.gigabyte.eu/Products/Motherboard/Products_Spec.aspx?ClassValue=Motherboard&amp;ProductID=2919&amp;ProductName=GA-EP45-UD3P" onclick="javascript:pageTracker._trackPageview('/external/www.gigabyte.eu/Products/Motherboard/Products_Spec.aspx');" >GA-EP45-UD3P</a>, and I&#8217;m running Windows 7 RC (7100) 64bit, but it seems to be reported for all 64 bit versions of Windows.  Anyhow, the fix itself is simple, and seems to stick over reboots, and hopefully it&#8217;s permanently fixed.</p>
<h2>Fixing the problem</h2>
<p>To solve the problem, we need to open an elevated command prompt; in both Windows 7 and Vista, you do this easily by hitting the Windows button, typing &#8220;cmd&#8221;, right-clicking the &#8220;C:\ cmd&#8221; search result, and selecting &#8220;Run as administrator&#8221;. In Windows 7 you can also find Command Prompt in the Start menu and Ctrl-Shift-click it, to open it elevated.</p>
<p>(Disclaimer: The DISKPART tool can potentially remove/create partitions on your hard drive, so be 100% certain what you&#8217;re doing before you hit Enter)</p>
<p>In the elevated Command Prompt, type “diskpart” and press enter:</p>
<div class="codecolorer-container dos 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="dos codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">C:\&gt; diskpart</div></td></tr></tbody></table></div>
<p>On the diskpart prompt, list your volumes:</p>
<div class="codecolorer-container dos 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="dos codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">DISKPART&gt; list volume</div></td></tr></tbody></table></div>
<p>In my case, the volume on my RAID was volume 4, so I selected it:</p>
<div class="codecolorer-container dos 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="dos codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">DISKPART&gt; select volume <span style="color: #cc66cc;">4</span></div></td></tr></tbody></table></div>
<p>…and then I marked it writeable like this:</p>
<div class="codecolorer-container dos 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="dos codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">DISKPART&gt; attributes volume clear readonly</div></td></tr></tbody></table></div>
<p>Here’s the entire segment in a screenshot (note that I did a couple of extra steps selecting the disk, this is apparently not necessary):</p>
<div id="attachment_34" class="wp-caption alignnone" style="width: 510px"><img class="size-full wp-image-34" title="DISKPART screenshot" src="http://www.lejordet.com/wp-content/uploads/2009/05/diskpart.png" alt="DISKPART commands for removing read-only" width="500" height="510" /><p class="wp-caption-text">DISKPART commands for removing read-only</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.lejordet.com/2009/05/raid1-write-protected-64bit-windows/feed/</wfw:commentRss>
		<slash:comments>0</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! -->