<?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>Lessan Vaezi</title>
	<atom:link href="http://www.lessanvaezi.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lessanvaezi.com</link>
	<description>Working for a better future through Information Technology and the Baha'i Faith</description>
	<lastBuildDate>Mon, 15 Oct 2012 20:37:04 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>How to clear the Clipboard when exiting Microsoft Word</title>
		<link>http://www.lessanvaezi.com/clear-the-clipboard-when-exiting-word/</link>
		<comments>http://www.lessanvaezi.com/clear-the-clipboard-when-exiting-word/#comments</comments>
		<pubDate>Fri, 09 Sep 2011 17:29:45 +0000</pubDate>
		<dc:creator>lessan</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[clipboard]]></category>
		<category><![CDATA[macro]]></category>
		<category><![CDATA[vba]]></category>
		<category><![CDATA[word]]></category>

		<guid isPermaLink="false">http://www.lessanvaezi.com/?p=253</guid>
		<description><![CDATA[This week a colleague approached me to consult about a problem he had encountered, where it was necessary to ensure that the Clipboard was empty when Microsoft Word exits. It was part of a legacy Word automation solution that he wasn&#8217;t in a position to change just yet, and it would crash if there was [...]]]></description>
				<content:encoded><![CDATA[<p>This week a colleague approached me to consult about a problem he had encountered, where it was necessary to ensure that the Clipboard was empty when Microsoft Word exits. It was part of a legacy Word automation solution that he wasn&#8217;t in a position to change just yet, and it would crash if there was anything left on the clipboard.</p>
<p>Two approaches came to mind, one using a Word VBA Macro, the other using a VSTO add-in. Here is an attempt at a solution for the first approach &#8211; let&#8217;s hope it fixes the problem.</p>
<p>You can hook into events using Word VBA quite easily, either by creating a macro with a special name (reference: <a href="http://msdn.microsoft.com/en-us/library/bb208800.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/bb208800.aspx</a>), or by setting up event handlers. In this case, we will use a macro called <em>AutoExit</em> which is invoked &#8220;when you exit Word or unload a global template&#8221;. We&#8217;ll save the macro in a template file and have it loaded as a global template, so this event should be ideal for our purposes.</p>
<p>The first step is to load Word and get to the Visual Basic editor (press Alt-F11). Here, double-click on the <em>ThisDocument</em> entry in the project explorer to open up a code window:</p>
<p><img src="http://www.lessanvaezi.com/wp-content/uploads/2011/09/word-vba-editor.png" alt="" title="word vba editor" width="417" height="273" class="aligncenter size-full wp-image-254" /></p>
<p>Then, copy and paste the following code (which I will explain soon) into the code window you just opened:</p>
<pre class="brush: vb; title: ; notranslate">
'Events: http://msdn.microsoft.com/en-us/library/bb208800.aspx
Sub AutoExit()
    ClearClipboard
End Sub

Sub ClearClipboard()
    Dim MyData As Object
    ' source: http://akihitoyamashiro.com/en/VBA/LateBindingDataObject.htm
    Set MyData = CreateObject(&quot;new:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}&quot;)
    MyData.SetText &quot;&quot;
    MyData.PutInClipboard
    Set MyData = Nothing
End Sub
</pre>
<p>Now save the document as a <em>Word Macro-Enabled Document Template (.dotm)</em> with a name such as <strong>ClearClipboardOnWordExit.dotm</strong>:</p>
<p><img src="http://www.lessanvaezi.com/wp-content/uploads/2011/09/word-save-as-dialog.png" alt="" title="word save as dialog" width="632" height="329" class="aligncenter size-full wp-image-255" /></p>
<p>Place this document in the Word Startup folder. By default, it should be <strong>%appdata%\Microsoft\Word\Startup</strong>, but you can find out where it really is by going to <em>Word Options</em>, <em>Advanced</em>, scrolling to the bottom and clicking on <em>File Locations</em>:</p>
<p><img src="http://www.lessanvaezi.com/wp-content/uploads/2011/09/word-options-file-locations.png" alt="" title="word options file locations" width="713" height="384" class="aligncenter size-full wp-image-256" /></p>
<p>Word will load any templates in this folder as global templates when it starts.</p>
<p>That&#8217;s about it! Now to test it, open Word afresh, type something and copy it to the clipboard. Then exit Word and check to confirm that the clipboard no longer has the text you just copied.</p>
<h3>Explanation of the code</h3>
<ul>
<li>The name of the macro, <em>AutoExit</em>, makes it get called when Word is closing:
<pre class="brush: vb; title: ; notranslate">
Sub AutoExit()
    ClearClipboard
End Sub
</pre>
</li>
<li>
Then we create a <strong>DataObject</strong>, which is part of the <em>Microsoft Forms 2.0 Object Library</em>. However, instead of adding a reference to it, I prefer using late binding so I found this page that describes how to do it using the <em>clsid</em>: <a href="http://akihitoyamashiro.com/en/VBA/LateBindingDataObject.htm" target="_blank">http://akihitoyamashiro.com/en/VBA/LateBindingDataObject.htm</a></p>
<pre class="brush: vb; title: ; notranslate">
    Dim MyData As Object
    Set MyData = CreateObject(&quot;new:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}&quot;)
</pre>
</li>
<li>Using this object, we set a blank string to the clipboard, effectively clearing it:
<pre class="brush: vb; title: ; notranslate">
    MyData.SetText &quot;&quot;
    MyData.PutInClipboard
</pre>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.lessanvaezi.com/clear-the-clipboard-when-exiting-word/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get email Headers from an Outlook MailItem</title>
		<link>http://www.lessanvaezi.com/email-headers-from-outlook-mailitem/</link>
		<comments>http://www.lessanvaezi.com/email-headers-from-outlook-mailitem/#comments</comments>
		<pubDate>Fri, 22 Jul 2011 05:46:53 +0000</pubDate>
		<dc:creator>lessan</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[add-in]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[extension method]]></category>
		<category><![CDATA[header]]></category>
		<category><![CDATA[mailitem]]></category>
		<category><![CDATA[outlook]]></category>
		<category><![CDATA[vsto]]></category>

		<guid isPermaLink="false">http://www.lessanvaezi.com/?p=243</guid>
		<description><![CDATA[While working on a VSTO add-in for Microsoft Outlook, I came across the need to access the headers of an email, to parse out X-CustomProperty tags that were put in by an application that sent the emails. However, I couldn&#8217;t find a Headers property in the Outlook object model, so below is an attempt to [...]]]></description>
				<content:encoded><![CDATA[<p>While working on a VSTO add-in for Microsoft Outlook, I came across the need to access the headers of an email, to parse out X-CustomProperty tags that were put in by an application that sent the emails.  However, I couldn&#8217;t find a Headers property in the Outlook object model, so below is an attempt to create one.</p>
<p>The Regex used is courtesy of John Gietzen&#8217;s answer on <a href="http://stackoverflow.com/questions/1669797/are-there-net-framework-methods-to-parse-an-email-mime/1669834#1669834" target="_blank">this</a> stackoverflow question.</p>
<pre class="brush: csharp; title: ; notranslate">
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Microsoft.Office.Interop.Outlook;

public static class MailItemExtensions
{
    private const string HeaderRegex =
        @&quot;^(?&lt;header_key&gt;[-A-Za-z0-9]+)(?&lt;seperator&gt;:[ \t]*)&quot; +
            &quot;(?&lt;header_value&gt;([^\r\n]|\r\n[ \t]+)*)(?&lt;terminator&gt;\r\n)&quot;;
    private const string TransportMessageHeadersSchema =
        &quot;http://schemas.microsoft.com/mapi/proptag/0x007D001E&quot;;

    public static string[] Headers(this MailItem mailItem, string name)
    {
        var headers = mailItem.HeaderLookup();
        if (headers.Contains(name))
            return headers[name].ToArray();
        return new string[0];
    }

    public static ILookup&lt;string, string&gt; HeaderLookup(this MailItem mailItem)
    {
        var headerString = mailItem.HeaderString();
        var headerMatches = Regex.Matches
            (headerString, HeaderRegex, RegexOptions.Multiline).Cast&lt;Match&gt;();
        return headerMatches.ToLookup(
            h =&gt; h.Groups[&quot;header_key&quot;].Value,
            h =&gt; h.Groups[&quot;header_value&quot;].Value);
    }

    public static string HeaderString(this MailItem mailItem)
    {
        return (string)mailItem.PropertyAccessor
            .GetProperty(TransportMessageHeadersSchema);
    }
}
</pre>
<p>Sample usage:</p>
<pre class="brush: csharp; title: ; notranslate">
string[] preparedByArray = mailItem.Headers(&quot;X-PreparedBy&quot;);
string preparedBy;
if (preparedByArray.Length == 1)
    preparedBy = preparedByArray[0];
else 
    preparedBy = &quot;&quot;;

string allHeaders = mailItem.HeaderString();
</pre>
<p><strong>Edit 2011/08/05</strong>:<br />
Thanks to Rob for the heads-up. I updated the code to return a Lookup instead of a Dictionary &#8211; this handles the case of multiple headers with the same name.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lessanvaezi.com/email-headers-from-outlook-mailitem/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How to filter select list options</title>
		<link>http://www.lessanvaezi.com/filter-select-list-options/</link>
		<comments>http://www.lessanvaezi.com/filter-select-list-options/#comments</comments>
		<pubDate>Mon, 11 Jul 2011 07:48:09 +0000</pubDate>
		<dc:creator>lessan</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[javascript jquery select]]></category>

		<guid isPermaLink="false">http://www.lessanvaezi.com/?p=227</guid>
		<description><![CDATA[Here&#8217;s a jQuery extension method to filter the elements of a select list (option tags). It binds to a textbox, and as you type in the textbox the select list gets filtered to match what you are typing. Parameters: textbox This could be a jQuery selector, a jQuery object, or a DOM object. selectSingleMatch This [...]]]></description>
				<content:encoded><![CDATA[<p>Here&#8217;s a jQuery extension method to filter the elements of a <em><a href="http://www.w3schools.com/TAGS/tag_select.asp" title="select tag" target="_blank">select</a></em> list (<em>option</em> tags). It binds to a textbox, and as you type in the textbox the select list gets filtered to match what you are typing.</p>
<pre class="brush: jscript; title: ; notranslate">
jQuery.fn.filterByText = function(textbox, selectSingleMatch) {
  return this.each(function() {
    var select = this;
    var options = [];
    $(select).find('option').each(function() {
      options.push({value: $(this).val(), text: $(this).text()});
    });
    $(select).data('options', options);
    $(textbox).bind('change keyup', function() {
      var options = $(select).empty().scrollTop(0).data('options');
      var search = $.trim($(this).val());
      var regex = new RegExp(search,'gi');

      $.each(options, function(i) {
        var option = options[i];
        if(option.text.match(regex) !== null) {
          $(select).append(
             $('&lt;option&gt;').text(option.text).val(option.value)
          );
        }
      });
      if (selectSingleMatch === true &amp;&amp; 
          $(select).children().length === 1) {
        $(select).children().get(0).selected = true;
      }
    });
  });
};
</pre>
<p>Parameters:</p>
<ul>
<li>
    <strong>textbox</strong><br />
    This could be a jQuery selector, a jQuery object, or a DOM object.
  </li>
<li>
    <strong>selectSingleMatch</strong><br />
    This is optional, if you set it to <em>true</em>, when the filtered list includes only one item, that item will be automatically selected.
  </li>
</ul>
<p>For example:</p>
<pre class="brush: jscript; title: ; notranslate">
$(function() {
  $('#select').filterByText($('#textbox'), true);
});  
</pre>
<p>Live example (or in a <a href="/wp-content/uploads/2011/07/filterByText.html" title="example" target="_blank">new window</a>):<br />
<iframe src="/wp-content/uploads/2011/07/filterByText.html" style="height:140px"></p>
<p>Your browser does not support iframes.</p>
<p></iframe></p>
<p>You can play around with it on jsbin: <a href="http://jsbin.com/egogeh/edit" target="_blank">http://jsbin.com/egogeh/edit</a></p>
<h3>What it does:</h3>
<p>When you invoke the function on a <em>select</em> object, it finds all child <em>option</em> tags and saves their text and values into an array. This array is saved to the <em>select</em> object itself as a HTML5 custom data attribute, called <em>data-options</em>. Then, when a <em>change</em> or <em>keyup</em> event fires on the associated textbox, the select list is emptied, and for any entries in the array that match the search text a new <em>option</em> element is created.</p>
<p><strong>Edit 2012-10-15</strong>: Added ScrollTop(0) to improve the way it works with long lists, thanks to a comment by <strong>xarel</strong> below.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lessanvaezi.com/filter-select-list-options/feed/</wfw:commentRss>
		<slash:comments>38</slash:comments>
		</item>
		<item>
		<title>Using Open XML SDK to get Custom Properties from a Word document</title>
		<link>http://www.lessanvaezi.com/custom-properties-from-word/</link>
		<comments>http://www.lessanvaezi.com/custom-properties-from-word/#comments</comments>
		<pubDate>Wed, 29 Jun 2011 12:17:15 +0000</pubDate>
		<dc:creator>lessan</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[open xml]]></category>
		<category><![CDATA[word]]></category>

		<guid isPermaLink="false">http://www.lessanvaezi.com/?p=217</guid>
		<description><![CDATA[I stumbled across a library that I didn&#8217;t realize was out there, for working with Microsoft Office documents. It only works with the newer Office 2007 and 2010 files (and 2003 with a compatibility pack), i.e. those using the Open XML standard. Download and install the Open XML SDK 2.0 for Microsoft Office: http://www.microsoft.com/download/en/details.aspx?displaylang=en&#038;id=5124. I [...]]]></description>
				<content:encoded><![CDATA[<p>I stumbled across a library that I didn&#8217;t realize was out there, for working with Microsoft Office documents. It only works with the newer Office 2007 and 2010 files (and 2003 with a compatibility pack), i.e. those using the <a href="http://en.wikipedia.org/wiki/Office_Open_XML" target="_blank">Open XML</a> standard.</p>
<p>Download and install the Open XML SDK 2.0 for Microsoft Office: <a href="http://www.microsoft.com/download/en/details.aspx?displaylang=en&#038;id=5124" target="_blank">http://www.microsoft.com/download/en/details.aspx?displaylang=en&#038;id=5124</a>.</p>
<p>I got the second, smaller file:</p>
<div style="text-align:center"><a href="http://www.microsoft.com/download/en/details.aspx?displaylang=en&#038;id=5124" target="_blank"><img src="http://www.lessanvaezi.com/wp-content/uploads/2011/06/openxml.png" alt="Open XML SDK 2.0 for Microsoft Office" width="660" height="178" /></a></div>
<p>Add a reference to <strong>DocumentFormat.OpenXml</strong> and <strong>WindowsBase</strong> to your project:</p>
<div style="text-align:center"><img src="http://www.lessanvaezi.com/wp-content/uploads/2011/06/references.png" width="230" height="96" /></div>
<p>You can now programmatically access Office documents, without the need to have Microsoft Office installed or any Interop DLLs. This works with Word, Excel and PowerPoint (using the OpenXML WordprocessingML, SpreadsheetML and PresentationML). </p>
<p>For example, to get the custom properties of a Word document:</p>
<pre class="brush: csharp; title: ; notranslate">
public static Dictionary&lt;string, string&gt; GetCustomPropertiesOfWordDocument
                                                  (string filename)
{
    using (var package = WordprocessingDocument.Open(filename, false))
    {
        var properties = new Dictionary&lt;string, string&gt;();
        foreach (var property in package.CustomFilePropertiesPart
            .Properties.Elements&lt;CustomDocumentProperty&gt;())
        {
            properties.Add(property.Name, property.VTLPWSTR.Text);
        }
        return properties;
    }
}
</pre>
<p>In this example, you would need to add some error handling around line 9 (<em>property.VTLPWSTR.Text</em>) as your property may be a different type or null.</p>
<p>When deploying your solution, you need to include <strong>DocumentFormat.OpenXml.dll</strong> with your application. You can set <em>Copy Local</em> to <em>True</em> in the properties for the reference, and it will be copied to your output folder when you compile the project:</p>
<div style="text-align:center"><img src="http://www.lessanvaezi.com/wp-content/uploads/2011/06/copylocal.png" alt="" title="copylocal" width="361" height="252" class="alignnone size-full wp-image-220" /></div>
<p>Download a sample project <a href="https://github.com/lessan/ExtractDocumentProperties" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lessanvaezi.com/custom-properties-from-word/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to hide the dotted border outline on focused elements in HTML, using CSS</title>
		<link>http://www.lessanvaezi.com/how-to-hide-the-dotted-border-outline-on-focused-elements-in-html-using-css/</link>
		<comments>http://www.lessanvaezi.com/how-to-hide-the-dotted-border-outline-on-focused-elements-in-html-using-css/#comments</comments>
		<pubDate>Sun, 10 Oct 2010 07:54:07 +0000</pubDate>
		<dc:creator>lessan</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[ie]]></category>

		<guid isPermaLink="false">http://www.lessanvaezi.com/?p=186</guid>
		<description><![CDATA[While working on a web application for data entry, I had to scour the net for a way to hide the dotted border that appears when an element is focused on a web page. Here are my findings. First, the obligatory disclaimer &#8211; I do understand that the dotted border is for accessibility purposes and [...]]]></description>
				<content:encoded><![CDATA[<p>While working on a web application for data entry, I had to scour the net for a way to hide the dotted border that appears when an element is focused on a web page. Here are my findings.</p>
<p>First, the obligatory disclaimer &#8211; I do understand that the dotted border is for accessibility purposes and should be left in place under normal circumstances. However, in this case we already had a replacement in place &#8211; when an element receives focus it is styled differently, using a very distinct background color. And this applies to all elements, regardless of whether they were selected by mouse or keyboard. So the dotted border is redundant, and somewhat distracting.</p>
<p>To further clarify the question, these are the dotted borders I refer to:<br />
<img style="vertical-align: middle; padding-left:50px;" src="http://www.lessanvaezi.com/wp-content/uploads/2010/10/save-outline.png" alt="save-outline" width="97" height="28" class="alignnone size-full wp-image-192" /> and <img style="vertical-align: middle;" src="http://www.lessanvaezi.com/wp-content/uploads/2010/10/cancel-outline.png" alt="cancel-outline" width="97" height="28" class="alignnone size-full wp-image-193" /></p>
<p>While the solution needed to be usable across browsers, the target browsers where well defined &#8211; modern versions of Firefox and Chrome, and IE 7 or newer. I first came across <a href="http://stackoverflow.com/questions/738319/when-i-click-on-a-link-most-browsers-draw-a-dotted-box-around-it-how-can-i-prev">this question</a> on stackoverflow.com which pointed me to using <em>outline:none</em>. Then <a href="http://stackoverflow.com/questions/71074/how-to-remove-firefoxs-dotted-outline-on-buttons-as-well-as-links">this one</a> helped with Firefox compatibility. And then I saw <a href="http://perishablepress.com/press/2008/12/16/unobtrusive-javascript-remove-link-focus-dotted-border-outlines/">this post</a> which provides a number of different techniques.</p>
<p>I ended up using the following CSS, which seems to cover most bases. As I didn&#8217;t see this combination on other sites I thought I would post it myself. It doesn&#8217;t apply to the <em>select</em> element in Firefox and IE7. Testing was done on Windows XP.</p>
<pre class="brush: css; gutter: false; title: ; notranslate">
/* hide the dotted lines around an element when it receives focus */
* { _noFocusLine: expression(this.hideFocus=true); } /* ie7 */
::-moz-focus-inner {border:0;}	                     /* firefox */
:focus {outline:none;}                               /* ie8, chrome, etc */
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.lessanvaezi.com/how-to-hide-the-dotted-border-outline-on-focused-elements-in-html-using-css/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Context is Hindi when printing line numbers in Word 2007</title>
		<link>http://www.lessanvaezi.com/context-is-hindi-when-printing-line-numbers-in-word-2007/</link>
		<comments>http://www.lessanvaezi.com/context-is-hindi-when-printing-line-numbers-in-word-2007/#comments</comments>
		<pubDate>Sun, 03 Jan 2010 09:42:33 +0000</pubDate>
		<dc:creator>lessan</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[context]]></category>
		<category><![CDATA[printing]]></category>
		<category><![CDATA[word 2007]]></category>

		<guid isPermaLink="false">http://www.lessanvaezi.com/?p=176</guid>
		<description><![CDATA[[This post accompanies a question posted here: http://superuser.com/questions/90665/context-is-hindi-when-printing-line-numbers-in-word-2007] I&#8217;m trying to print a Word 2007 document with Line Numbering turned on, and in Word the document looks fine but when I print the document, the line numbers appear in Hindi script. On screen: Printed: I tried deleting my Normal template and allowing Word to create [...]]]></description>
				<content:encoded><![CDATA[<p>[<em>This post accompanies a question posted here: </em><a href="http://superuser.com/questions/90665/context-is-hindi-when-printing-line-numbers-in-word-2007">http://superuser.com/questions/90665/context-is-hindi-when-printing-line-numbers-in-word-2007</a>]</p>
<p>I&#8217;m trying to print a Word 2007 document with Line Numbering turned on, and in Word the document looks fine but when I print the document, the line numbers appear in Hindi script.</p>
<div>On screen:</div>
<div style="padding-left: 30px;"><img class="size-full wp-image-177 alignnone" title="testing line numbers" src="http://www.lessanvaezi.com/wp-content/uploads/2010/01/testing-line-numbers.png" alt="" width="217" height="268" /></div>
<div>Printed:</div>
<div style="padding-left: 30px;"><img class="alignnone size-full wp-image-178" title="printed" src="http://www.lessanvaezi.com/wp-content/uploads/2010/01/printed.png" alt="" width="196" height="231" /></div>
<div>
<p>I tried deleting my Normal template and allowing Word to create a new one, and testing using that, with no change. I also tried different printers.</p>
</div>
<div>The problem goes away if I choose <em>Arabic</em> instead of <em>Context</em> under <strong>Word Options</strong> -&gt; <strong>Advanced</strong> -&gt; Show Document Content / Numeral:</div>
<div style="padding-left: 30px;"><img class="alignnone size-full wp-image-179" title="word advanced options" src="http://www.lessanvaezi.com/wp-content/uploads/2010/01/word-advanced-options.png" alt="" width="317" height="177" /></div>
<p>However, I would like to keep the setting as Context. The question is, <strong>why is the default context of my document Hindi script?</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lessanvaezi.com/context-is-hindi-when-printing-line-numbers-in-word-2007/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Registry settings to add Uninstall as a shell option for VSTO manifest files</title>
		<link>http://www.lessanvaezi.com/registry-settings-to-add-uninstall-as-a-shell-option-for-vsto-manifest-files/</link>
		<comments>http://www.lessanvaezi.com/registry-settings-to-add-uninstall-as-a-shell-option-for-vsto-manifest-files/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 17:25:03 +0000</pubDate>
		<dc:creator>lessan</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[add-in]]></category>
		<category><![CDATA[ClickOnce]]></category>
		<category><![CDATA[registry]]></category>
		<category><![CDATA[uninstall]]></category>
		<category><![CDATA[vsto]]></category>

		<guid isPermaLink="false">http://www.lessanvaezi.com/?p=132</guid>
		<description><![CDATA[I have been working on some VSTO add-ins and on deploying them, and have something to share that I didn&#8217;t find anywhere else. First of all, let me just say that despite certain hurdles, deploying using ClickOnce has been a very pleasant experience. After following some tutorials on making an MSI, we eventually ended up [...]]]></description>
				<content:encoded><![CDATA[<div id="attachment_141" class="wp-caption alignright" style="width: 265px"><img class="size-full wp-image-141 " title="Visual Studio Tools for the Microsoft Office System (VSTO)" src="http://www.lessanvaezi.com/wp-content/uploads/2009/09/vsto-logo.png" alt="vsto logo" width="255" height="152" /><p class="wp-caption-text">Visual Studio Tools for the Microsoft Office System (VSTO)</p></div>
<p>I have been working on some <a href="http://en.wikipedia.org/wiki/Visual_Studio_Tools_for_Office">VSTO</a> add-ins and on deploying them, and have something to share that I didn&#8217;t find anywhere else.</p>
<p>First of all, let me just say that despite certain hurdles, deploying using <a href="http://en.wikipedia.org/wiki/ClickOnce">ClickOnce</a> has been a very pleasant experience. After following some tutorials on making an MSI, we eventually ended up simply deploying the few needed registry entries to all users, which take care of installing and trusting each add-in. Then, once the add-in is installed, it takes care of updating itself every so often.</p>
<p>Unfortunately, during the period of figuring this out a few users got an older version then a newer version with a new signing certificate, which is I suspect the reason why they get the following error message:</p>
<pre>Specified argument was out of the range of valid values.
Parameter name: entryValue

Exception Text
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: entryValue
  at Microsoft.VisualStudio.Tools.Applications.Deployment.RegistryStore.Retrieve(String entryName, Object entryValue, CompareDelegate compareMethod)
  at Microsoft.VisualStudio.Tools.Applications.Deployment.MetadataStore.UpdateLastCheckedTime(String subscriptionID, DateTime newLastCheckedTime)
  at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.InstallAddIn()</pre>
<p>There is some discussion of this error <a href="http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/2e35c723-0182-414a-b391-548ffd878d62">here</a>.</p>
<p>Anyway, I tried removing the folder: <em>C:\Documents and Settings\%username%\Local Settings\Apps\2.0</em> which causes the add-ins to re-install themselves, but that didn&#8217;t fix the problem.</p>
<p>The second solution I tried worked, which was to uninstall the add-in and then re-install it again. One way to uninstall is to do so via <em>Add/Remove programs</em> (still using XP lingo), but I came across another way from <a href="http://weblogs.asp.net/cschittko/archive/2007/11/02/tool-for-uninstalling-vsto-add-ins.aspx">this blog post at ChristophDotNet</a>: simply run this command:</p>
<pre class="brush: plain; gutter: false; title: ; notranslate">C:\Program Files\Common Files\Microsoft Shared\VSTO\9.0\VSTOinstaller.exe
     /uninstall &amp;lt;name-of-manifest-file.vsto&amp;gt;</pre>
<p>I find this way much easier than waiting for the Add/Remove dialog to populate (takes a while on my bloated box). You can read more about the VSTOInstaller <a href="http://msdn.microsoft.com/en-us/library/bb772078(VS.100).aspx">on MSDN</a>.</p>
<p>After using this technique for a while, I realized one thing &#8211; to install an MSI file, you right-click on it and choose Install, and you can also right-click to Uninstall. However, with .vsto files, you can only install. Why not add the uninstall capability right there using a shell command? And now that I knew what the command was, it was trivial. First, to find out where in the registry the open command is defined, I came across <a href="http://blogs.msdn.com/nikhil/archive/2007/08/27/vsto-file-type-mapping-lost.aspx">this post on Nikhil&#8217;s blog</a>. Then, I simply added an uninstall component to it:</p>
<pre class="brush: plain; gutter: false; title: ; notranslate">
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\bootstrap.vsto.1\shell\uninstall]
@=&quot;Uninstall&quot;

[HKEY_CLASSES_ROOT\bootstrap.vsto.1\shell\uninstall\command]
@=&quot;\&quot;C:\\Program Files\\Common Files\\microsoft shared\\VSTO\\9.0\\VSTOInstaller.exe\&quot; /uninstall \&quot;%1\&quot;&quot;
</pre>
<p>Put that in a .reg file and run it, and you&#8217;ll be able to uninstall VSTO add-ins with ease!</p>
<p><em>This post applies to VSTO version 3.0.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lessanvaezi.com/registry-settings-to-add-uninstall-as-a-shell-option-for-vsto-manifest-files/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Recursive Active Directory group membership using System.DirectoryServices in .NET 3.5</title>
		<link>http://www.lessanvaezi.com/recursive-active-directory-group-membership-using-system-directoryservices-in-net-3-5/</link>
		<comments>http://www.lessanvaezi.com/recursive-active-directory-group-membership-using-system-directoryservices-in-net-3-5/#comments</comments>
		<pubDate>Sat, 22 Aug 2009 09:57:39 +0000</pubDate>
		<dc:creator>lessan</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.lessanvaezi.com/?p=125</guid>
		<description><![CDATA[When coding for an organization that uses Active Directory, you will eventually come across the business case for using groups within groups, i.e. a  user is part of say, the HR-Administration group, and that group is itself a member of the HR-Department group. You may then need to secure your application to only allow members [...]]]></description>
				<content:encoded><![CDATA[<p>When coding for an organization that uses Active Directory, you will eventually come across the business case for using groups within groups, i.e. a  user is part of say, the <em>HR-Administration</em> group, and that group is itself a member of the <em>HR-Department</em> group. You may then need to secure your application to only allow members of <em>HR-Department</em> to access certain functionality within it,  and so you need an <strong>IsUserInGroup</strong> function, but one that looks recursively at groups that are members of the requested group.</p>
<p>Over the years I&#8217;ve had to come up with such a function in various technologies: VB6 using <a href="http://msdn.microsoft.com/en-us/library/ms806997.aspx" target="_blank">ADSI</a>, PHP using the <a href="http://www.php.net/manual/en/book.ldap.php" target="_blank">php_ldap</a> extension, and System.DirectoryServices in .NET 2.0 with a custom function for recursing. </p>
<p>A few weeks ago I was using .NET 3.5 and decided to look around again to see if there was an easy alternative. It seems the 3.5 release comes with a revamped System.DirectoryServices which makes things much easier for common use cases. And although there is no function to achieve what we need, there is one that helps us do it: group.<strong><a href="http://msdn.microsoft.com/en-us/library/bb339975.aspx" target="_blank">GetMembers</a></strong>(<em>true</em>).  The parameter when set to <em>true</em> triggers a recursive search of all groups that are members of the current group, and grabs their members too. So it becomes trivial to achieve an IsUserInGroup function:</p>
<pre class="brush: csharp; title: ; notranslate">
using System.DirectoryServices.AccountManagement;

...

public static bool IsUserInGroup(string username, string groupname)
{
    var foundUser = false;
    using (var context = new PrincipalContext(ContextType.Domain, &quot;microsoft.com&quot;))
    using (var group = GroupPrincipal.FindByIdentity(context, groupname))
    {
        if (group == null)
        {
            throw new ArgumentException(&quot;Group could not be found: &quot; + groupname);
        }

        // GetMembers(true) is recursive (groups-within-groups)
        foreach (var member in group.GetMembers(true))
        {
            if (member.SamAccountName.Equals(username))
            {
                foundUser = true;
                break;
            }
        }
    }
    return foundUser;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.lessanvaezi.com/recursive-active-directory-group-membership-using-system-directoryservices-in-net-3-5/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Now using Windows 7 Release Candidate</title>
		<link>http://www.lessanvaezi.com/now-using-windows-7-release-candidate/</link>
		<comments>http://www.lessanvaezi.com/now-using-windows-7-release-candidate/#comments</comments>
		<pubDate>Tue, 05 May 2009 21:09:42 +0000</pubDate>
		<dc:creator>lessan</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[windows 7]]></category>

		<guid isPermaLink="false">http://www.lessanvaezi.com/?p=110</guid>
		<description><![CDATA[I recently installed Windows 7 &#8211; which is currently being developed and will be released in the next few months &#8211; on my home computer. I had heard good things about it, and was keen to test out this latest preview version. It replaced my 6-month old XP installation. Here are some screenshots of things [...]]]></description>
				<content:encoded><![CDATA[<p style="direction: ltr;">I recently installed Windows 7 &#8211; which is currently being developed and will be released in the next few months &#8211; on my home computer. I had heard good things about it, and was keen to test out this latest preview version. It replaced my 6-month old XP installation. Here are some screenshots of things that stood out to me in the new Windows.</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-120" title="Windows 7 logo" src="http://www.lessanvaezi.com/wp-content/uploads/2009/05/windows7.png" alt="windows7" width="100" height="63" /></p>
<p style="direction: ltr;">The installation went very smoothly, took somewhere around 30 minutes (had to go away from the computer and come back so couldn&#8217;t tell exactly how long it took). The first thing I noticed, it installed drivers for my video card, then detected the monitors connected and figured out their maximum resolutions, and set Windows to those resolutions as well as the side-by-side layout of the monitors. Everything worked perfectly! Quite impressed. To change these settings further, the interface looks like this:</p>
<p><img class="aligncenter size-full wp-image-112" title="display" src="http://www.lessanvaezi.com/wp-content/uploads/2009/05/display.png" alt="display" width="508" height="548" /></p>
<p>Another change was with themes. They now seem more well integrated, with sound schemes and lists of wallpapers to go along with each theme. When you click on the theme it changes to it there and then, and very quickly. You also hear a preview sound from that theme, which makes for a great choosing experience:</p>
<p><img class="aligncenter size-full wp-image-117" title="themes" src="http://www.lessanvaezi.com/wp-content/uploads/2009/05/themes.png" alt="themes" width="743" height="608" /></p>
<p>The quick launch area next to the Start menu has gotten a revamp &#8211; mouse over also shows a preview of all the windows of that type that are open:</p>
<p><img class="aligncenter size-full wp-image-119" title="quick-launch" src="http://www.lessanvaezi.com/wp-content/uploads/2009/05/quick-launch.png" alt="quick-launch" width="306" height="50" /></p>
<p>One of the new features is <em>Libraries</em>, which are special folders that show files from different sources. You get to define which paths these files come from, but they all show together in one convenient view:</p>
<p><img class="aligncenter size-full wp-image-115" title="libraries" src="http://www.lessanvaezi.com/wp-content/uploads/2009/05/libraries.png" alt="libraries" width="703" height="531" />Of course, the icons themselves are new, and rendered very beautifully &#8211; I just noticed the Control Panel icon which looks very nice:</p>
<p><img class="aligncenter size-full wp-image-114" title="icons" src="http://www.lessanvaezi.com/wp-content/uploads/2009/05/icons.png" alt="icons" width="583" height="346" />Starting to test out other features &#8211; the desktop <em>Gadgets </em>are there just like Vista, but worked really well and fast for me:</p>
<p><img class="aligncenter size-full wp-image-113" title="gadgets" src="http://www.lessanvaezi.com/wp-content/uploads/2009/05/gadgets.png" alt="gadgets" width="323" height="397" /></p>
<p>There is a new item in the Control Panel called <em>Devices and Printers</em>. This seems to provide a much more convenient location to see your installed hardware and configure them. Each icon represents a type of device, and they all have their own context menus of actions:</p>
<p><img class="aligncenter size-full wp-image-111" title="devices" src="http://www.lessanvaezi.com/wp-content/uploads/2009/05/devices.png" alt="devices" width="691" height="612" /></p>
<p>Thats about it for what I noticed in the first few minutes. Microsoft Paint also got an interface lift:</p>
<p><img class="aligncenter size-full wp-image-116" title="paint" src="http://www.lessanvaezi.com/wp-content/uploads/2009/05/paint.png" alt="paint" width="543" height="578" /></p>
<p>So far the experience has been quite pleasant &#8211; very responsive and fast, sleek polished UI, high availability of drivers and installation seems very well automated, and stable &#8211; haven&#8217;t had any crashes yet.</p>
<p>If you would like to try it out for yourself, here&#8217;s the link:</p>
<div style="direction: ltr;"><a href="http://www.microsoft.com/windows/windows-7/download.aspx"><img class="size-full wp-image-118 aligncenter" title="Download Windows 7 RC" src="http://www.lessanvaezi.com/wp-content/uploads/2009/05/win7_subhero_downloadrc.gif" alt="win7_subhero_downloadrc" width="200" height="107" /></a></div>
<div style="direction: ltr;"></div>
<div style="direction: ltr;"></div>
]]></content:encoded>
			<wfw:commentRss>http://www.lessanvaezi.com/now-using-windows-7-release-candidate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Prezi for stunning presentations</title>
		<link>http://www.lessanvaezi.com/prezi-for-stunning-presentations/</link>
		<comments>http://www.lessanvaezi.com/prezi-for-stunning-presentations/#comments</comments>
		<pubDate>Mon, 16 Feb 2009 14:55:27 +0000</pubDate>
		<dc:creator>lessan</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[powerpoint]]></category>
		<category><![CDATA[presentations]]></category>
		<category><![CDATA[prezi]]></category>
		<category><![CDATA[wf]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[workflow]]></category>

		<guid isPermaLink="false">http://www.lessanvaezi.com/?p=96</guid>
		<description><![CDATA[Some days ago I was introduced to this website: prezi.com, for creating presentations online. The editor uses Flash and is entirely online, and you can upload pictures, videos and other flash animations to it. Anyway, I had signed up for their closed beta and earlier today I received a login. The timing was quite fortuitous [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://prezi.com/"><img class="alignright size-full wp-image-101" style="margin-left: 10px" title="Prezi logo" src="http://www.lessanvaezi.com/wp-content/uploads/2009/02/prezi-logo.png" alt="Prezi logo" width="300" height="120" /></a>Some days ago I was introduced to this website: <a href="http://prezi.com">prezi.com</a>, for creating presentations online. The editor uses Flash and is entirely online, and you can upload pictures, videos and other flash animations to it.</p>
<p>Anyway, I had signed up for their closed beta and earlier today I received a login. The timing was quite fortuitous as I had a presentation scheduled for later in the day and decided to re-do the PowerPoint slides on Prezi. It was quite quick to do, and I exported some of the elements from the PowerPoint presentation and uploaded them to Prezi &#8211; took maybe two or three hours in total.</p>
<p>Here&#8217;s the resulting creation:</p>
<p style="text-align: center;"><a href="http://prezi.com/8597/" target="_blank"><img class="size-medium wp-image-97 aligncenter" title="Prezi screenshot - Windows Workflow Foundation" src="http://www.lessanvaezi.com/wp-content/uploads/2009/02/wf-300x207.png" alt="Prezi screenshot - Windows Workflow Foundation" width="300" height="207" /></a></p>
<p>Click through to open and view it. When viewing, use the arrows in the bottom right corner to navigate:</p>
<p><img class="aligncenter size-full wp-image-100" title="Prezi - Navigation" src="http://www.lessanvaezi.com/wp-content/uploads/2009/02/prezi-navigation.png" alt="Prezi - Navigation" width="161" height="54" /></p>
<p>Or you can simply click on an object to zoom in on it.</p>
<p> </p>
<p>The editor is also quite neat &#8211; there is a round menu system:</p>
<p><img class="aligncenter size-full wp-image-98" title="Prezi menu" src="http://www.lessanvaezi.com/wp-content/uploads/2009/02/prezi-menu.png" alt="Prezi menu" width="606" height="389" /></p>
<p>And when you click on a shape you can move/scale/rotate it with this round control:</p>
<p><img class="aligncenter size-full wp-image-99" title="Prezi - Round menu" src="http://www.lessanvaezi.com/wp-content/uploads/2009/02/prezi-round-menu.png" alt="Prezi - Round menu" width="327" height="235" /></p>
<p>Very innovative interface! This promises to be a popular online resource. Visit their site and sign up, and you can play around with the demos.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lessanvaezi.com/prezi-for-stunning-presentations/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
