<?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; office</title>
	<atom:link href="http://www.lejordet.com/category/windows/office/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, 31 Jan 2012 19:37:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>&#8220;Microsoft Dynamics CRM for Outlook with Offline Access has already been configured for a user on this computer. Only one use can be configured per computer for Microsoft CRM for Outlook with Offline Access.&#8221;</title>
		<link>http://www.lejordet.com/2010/09/microsoft-dynamics-crm-for-outlook-with-offline-access-has-already-been-configured-for-a-user-on-this-computer-only-one-use-can-be-configured-per-computer-for-microsoft-crm-for-outlook-with-offline/</link>
		<comments>http://www.lejordet.com/2010/09/microsoft-dynamics-crm-for-outlook-with-offline-access-has-already-been-configured-for-a-user-on-this-computer-only-one-use-can-be-configured-per-computer-for-microsoft-crm-for-outlook-with-offline/#comments</comments>
		<pubDate>Fri, 03 Sep 2010 11:46:57 +0000</pubDate>
		<dc:creator>Lars Erik Jordet</dc:creator>
				<category><![CDATA[office]]></category>
		<category><![CDATA[quick]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[dynamics]]></category>
		<category><![CDATA[win32]]></category>

		<guid isPermaLink="false">http://www.lejordet.com/?p=126</guid>
		<description><![CDATA["Microsoft Dynamics CRM for Outlook with Offline Access has already been configured for a user on this computer. Only one use can be configured per computer for Microsoft CRM for Outlook with Offline Access." - how to configure Dynamics for a different user.]]></description>
			<content:encoded><![CDATA[<p>If you try to swap users on a laptop, with Dynamics CRM installed in Offline Access mode, it will give the error above; searching gave me 
<a  href="http://blogs.technet.com/b/crmchina/archive/2010/06/04/quot-microsoft-dynamics-crm-for-outlook-with-offline-access-has-already-been-configured-for-a-user-on-this-computer-only-one-use-can-be-configured-per-computer-for-microsoft-crm-for-outlook-with-offline-access-quot.aspx" onclick="javascript:pageTracker._trackPageview('/external/blogs.technet.com/b/crmchina/archive/2010/06/04/quot-microsoft-dynamics-crm-for-outlook-with-offline-access-has-already-been-configured-for-a-user-on-this-computer-only-one-use-can-be-configured-per-computer-for-microsoft-crm-for-outlook-with-offline-access-quot.aspx');" >this page from the Chinese Dynamics CRM team</a>, so I&#8217;m just going to repeat it here:</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 />2<br />3<br />4<br /></div></td><td><div class="dos codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; C:\<span style="color: #33cc33;">&gt;</span>osql –E –S localhost\CRM<br />
&nbsp; &nbsp; &nbsp; 1<span style="color: #33cc33;">&gt;</span> drop database mscrm_msde<br />
&nbsp; &nbsp; &nbsp; 2<span style="color: #33cc33;">&gt;</span> go<br />
&nbsp; &nbsp; &nbsp; 1<span style="color: #33cc33;">&gt;</span> quit</div></td></tr></tbody></table></div>
<p>Basically, you connect to the SQL Server on the local computer, and delete the Offline Access database, allowing you to reconfigure as normal. Note that this won&#8217;t let you reconfigure the user as &#8220;online only&#8221; &#8211; the new configuration will automatically be Offline Access.</p>
<p>Secondly, this works even if the user is not Local Administrator on the computer.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lejordet.com/2010/09/microsoft-dynamics-crm-for-outlook-with-offline-access-has-already-been-configured-for-a-user-on-this-computer-only-one-use-can-be-configured-per-computer-for-microsoft-crm-for-outlook-with-offline/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: #E56717; font-weight: bold;">Option</span> <span style="color: #E56717; font-weight: bold;">Explicit</span><br />
<br />
<span style="color: #E56717; font-weight: bold;">Public</span> <span style="color: #8D38C9; font-weight: bold;">WithEvents</span> odist <span style="color: #151B8D; font-weight: bold;">As</span> PdfDistiller<br />
Attribute odist.VB_VarHelpID = -1<br />
<span style="color: #151B8D; font-weight: bold;">Dim</span> StartTime <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">Date</span><br />
<br />
<span style="color: #E56717; font-weight: bold;">Private</span> <span style="color: #E56717; font-weight: bold;">Sub</span> Class_Initialize()<br />
&nbsp;<span style="color: #151B8D; font-weight: bold;">Set</span> odist = <span style="color: #E56717; font-weight: bold;">New</span> PdfDistiller<br />
<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #E56717; font-weight: bold;">Sub</span><br />
<br />
<span style="color: #E56717; font-weight: bold;">Private</span> <span style="color: #E56717; font-weight: bold;">Sub</span> odist_OnJobDone(<span style="color: #151B8D; font-weight: bold;">ByVal</span> strInputPostScript <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">String</span>, <span style="color: #151B8D; font-weight: bold;">ByVal</span> strOutputPDF <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">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: #8D38C9; font-weight: bold;">End</span> <span style="color: #E56717; font-weight: bold;">Sub</span><br />
<br />
<span style="color: #E56717; font-weight: bold;">Private</span> <span style="color: #E56717; font-weight: bold;">Sub</span> odist_OnJobFail(<span style="color: #151B8D; font-weight: bold;">ByVal</span> strInputPostScript <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">String</span>, <span style="color: #151B8D; font-weight: bold;">ByVal</span> strOutputPDF <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">String</span>)<br />
<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #E56717; font-weight: bold;">Sub</span><br />
<br />
<span style="color: #E56717; font-weight: bold;">Private</span> <span style="color: #E56717; font-weight: bold;">Sub</span> odist_OnJobStart(<span style="color: #151B8D; font-weight: bold;">ByVal</span> strInputPostScript <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">String</span>, <span style="color: #151B8D; font-weight: bold;">ByVal</span> strOutputPDF <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">String</span>)<br />
<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #E56717; font-weight: bold;">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: #E56717; font-weight: bold;">Sub</span> PrintToPDF(sPDFFileName, SheetName)<br />
<br />
&nbsp;<span style="color: #151B8D; font-weight: bold;">Dim</span> sPSFileName <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">String</span> <span style="color: #008000;">'Name of PS to be created<br />
</span> <span style="color: #151B8D; font-weight: bold;">Dim</span> sJobOptions <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">String</span><br />
&nbsp;<span style="color: #151B8D; font-weight: bold;">Dim</span> sCurrentPrinter <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">String</span> <span style="color: #008000;">'Same current printer choice to resume at end<br />
</span> <span style="color: #151B8D; font-weight: bold;">Dim</span> sPDFVersionAndPort <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">String</span> <span style="color: #008000;">'Version of Adobe<br />
</span> <span style="color: #151B8D; font-weight: bold;">Dim</span> sDummyPrinter <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">String</span> <span style="color: #008000;">' Need a dummy printer to produce the PS<br />
</span> <span style="color: #151B8D; font-weight: bold;">Dim</span> appDist <span style="color: #151B8D; font-weight: bold;">As</span> cAcroDist<br />
<br />
&nbsp;<span style="color: #151B8D; font-weight: bold;">Set</span> appDist = <span style="color: #E56717; font-weight: bold;">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: #00C2FF; font-weight: bold;">True</span>, PrToFileName:=sPSFileName <span style="color: #008000;">'Prints to PS<br />
</span><br />
&nbsp;<span style="color: #E56717; font-weight: bold;">Call</span> appDist.odist.FileToPDF(sPSFileName, sPDFFileName, sJobOptions) <span style="color: #008000;">'Creates PDF<br />
</span><br />
&nbsp;<span style="color: #151B8D; font-weight: bold;">On</span> <span style="color: #151B8D; font-weight: bold;">Error</span> <span style="color: #151B8D; font-weight: bold;">Resume</span> <span style="color: #8D38C9; font-weight: bold;">Next</span><br />
&nbsp;Kill sPSFileName <span style="color: #008000;">'Removes PS<br />
</span> <span style="color: #151B8D; font-weight: bold;">On</span> <span style="color: #151B8D; font-weight: bold;">Error</span> <span style="color: #8D38C9; font-weight: bold;">GoTo</span> 0<br />
<br />
&nbsp;Application.ActivePrinter = sCurrentPrinter <span style="color: #008000;">'Change back to the original printer<br />
</span><span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #E56717; font-weight: bold;">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: #151B8D; font-weight: bold;">Dim</span> Prt_On <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">String</span><br />
<br />
<span style="color: #E56717; font-weight: bold;">Function</span> NetworkPrinter(<span style="color: #151B8D; font-weight: bold;">ByVal</span> myprinter <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">String</span>)<br />
&nbsp;<span style="color: #151B8D; font-weight: bold;">On</span> <span style="color: #151B8D; font-weight: bold;">Error</span> <span style="color: #151B8D; font-weight: bold;">Resume</span> <span style="color: #8D38C9; font-weight: bold;">Next</span><br />
<br />
&nbsp;<span style="color: #151B8D; font-weight: bold;">Dim</span> NetWork <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">Variant</span><br />
&nbsp;<span style="color: #151B8D; font-weight: bold;">Dim</span> X <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">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: #151B8D; font-weight: bold;">On</span> <span style="color: #151B8D; font-weight: bold;">Error</span> <span style="color: #151B8D; font-weight: bold;">Resume</span> <span style="color: #8D38C9; font-weight: bold;">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: #8D38C9; font-weight: bold;">If</span> Err.Number &lt;&gt; 0 <span style="color: #8D38C9; font-weight: bold;">And</span> X &lt; <span style="color: #151B8D; font-weight: bold;">UBound</span>(NetWork) <span style="color: #8D38C9; font-weight: bold;">Then</span><br />
&nbsp; &nbsp; X = X + 1<br />
&nbsp; &nbsp; <span style="color: #8D38C9; font-weight: bold;">GoTo</span> TryAgain<br />
&nbsp; <span style="color: #8D38C9; font-weight: bold;">ElseIf</span> Err.Number &lt;&gt; 0 <span style="color: #8D38C9; font-weight: bold;">And</span> X &gt; <span style="color: #151B8D; font-weight: bold;">UBound</span>(NetWork) - 1 <span style="color: #8D38C9; font-weight: bold;">Then</span><br />
&nbsp;<span style="color: #8D38C9; font-weight: bold;">GoTo</span> PrtError<br />
&nbsp;<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #8D38C9; font-weight: bold;">If</span><br />
&nbsp;<span style="color: #151B8D; font-weight: bold;">On</span> <span style="color: #151B8D; font-weight: bold;">Error</span> <span style="color: #8D38C9; font-weight: bold;">GoTo</span> 0<br />
&nbsp;NetworkPrinter = myprinter &amp; Prt_On &amp; NetWork(X)<br />
errorExit:<br />
&nbsp;<span style="color: #E56717; font-weight: bold;">Exit</span> <span style="color: #E56717; font-weight: bold;">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: #151B8D; font-weight: bold;">Resume</span> errorExit<br />
<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #E56717; font-weight: bold;">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! -->
